Added to the performance tab of the doc
This commit is contained in:
+84
@@ -3111,3 +3111,87 @@ J'ai fait un manuel qui décrit à peu près tout ce qui'il faut savoir pour bie
|
||||
Aujourd'hui je vais continuer à documenter... Ma methode pour l'instant c'est juste de remplir les titres que j'ai prévu au départ. Ensuite à partir de jeudi (je pense que c'est à partir de cette date que j'aurai un peu tout rempli) j'aimerais bien relire la grille d'évaluation et ensuite faire une lecture de mon journal de bord pour vérifier que je n'ai rien oublié. Et le but c'est de finir la doc Vendredi soir pour faire une dernière release doc + projet.
|
||||
|
||||
Un collègue M.Briard m'a pas mal aidé avec la configuration de mon mkdocs et il a développé une extension pour ajouter le code source au PDF final. La il est en train de regarder si il peut trouver un moyen de faire une table des figures qui nous est demandée. (j'ai plus de 200 images dans ma documentation alors si c'est possible de ne pas avoir à faire une table des figures à la main je prends)
|
||||
|
||||
## Mercredi 7 Juin
|
||||
|
||||
La je suis en train de parler de l'optimisation de mon application et je viens de me rappeller qu'il manquait des methodes avec de la paralellisation alors je vais les convertir avant de continuer la doc.
|
||||
|
||||
En fait je viens de me rendre compte qu'aucunes de mes methodes de filtres n'étaient en parralel... Je ne sais pas si jaurai le temps de le faire aujourd'hui en fait
|
||||
|
||||
|
||||
Voici le code avant la paralellisation :
|
||||
|
||||
```Csharp
|
||||
public static Bitmap VanishOxyAction(Bitmap inputBitmap)
|
||||
{
|
||||
Rectangle rect = new Rectangle(0, 0, inputBitmap.Width, inputBitmap.Height);
|
||||
BitmapData bmpData = inputBitmap.LockBits(rect, ImageLockMode.ReadWrite, inputBitmap.PixelFormat);
|
||||
int bytesPerPixel = Bitmap.GetPixelFormatSize(inputBitmap.PixelFormat) / 8;
|
||||
|
||||
unsafe
|
||||
{
|
||||
byte* ptr = (byte*)bmpData.Scan0.ToPointer();
|
||||
for (int y = 0; y < inputBitmap.Height; y++)
|
||||
{
|
||||
byte* currentLine = ptr + (y * bmpData.Stride);
|
||||
for (int x = 0; x < inputBitmap.Width; x++)
|
||||
{
|
||||
byte* pixel = currentLine + (x * bytesPerPixel);
|
||||
|
||||
int blue = (int)pixel[0];
|
||||
int green = (int)pixel[1];
|
||||
int red = (int)pixel[2];
|
||||
|
||||
int max = Math.Max(Math.Max(blue, green), red);
|
||||
|
||||
if (max > 255 / 3)
|
||||
max = 255;
|
||||
|
||||
pixel[0] = pixel[1] = pixel[2] = (byte)max;
|
||||
}
|
||||
}
|
||||
}
|
||||
inputBitmap.UnlockBits(bmpData);
|
||||
|
||||
return inputBitmap;
|
||||
}
|
||||
```
|
||||
|
||||
Et voici à quoi ca ressemble avec la paralellisation :
|
||||
|
||||
```Csharp
|
||||
public Bitmap VanishOxyAction(Bitmap inputBitmap)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
BitmapData bitmapData = inputBitmap.LockBits(new Rectangle(0, 0, inputBitmap.Width, inputBitmap.Height), ImageLockMode.ReadWrite, inputBitmap.PixelFormat);
|
||||
|
||||
int bytesPerPixel = System.Drawing.Bitmap.GetPixelFormatSize(inputBitmap.PixelFormat) / 8;
|
||||
int heightInPixels = bitmapData.Height;
|
||||
int widthInBytes = bitmapData.Width * bytesPerPixel;
|
||||
byte* PtrFirstPixel = (byte*)bitmapData.Scan0;
|
||||
|
||||
Parallel.For(0, heightInPixels, y =>
|
||||
{
|
||||
byte* currentLine = PtrFirstPixel + (y * bitmapData.Stride);
|
||||
for (int x = 0; x < widthInBytes; x = x + bytesPerPixel)
|
||||
{
|
||||
int blue = currentLine[x];
|
||||
int green = currentLine[x + 1];
|
||||
int red = currentLine[x + 2];
|
||||
|
||||
int max = Math.Max(Math.Max(blue, green), red);
|
||||
|
||||
if (max > 255 / 3)
|
||||
max = 255;
|
||||
|
||||
currentLine[x] = currentLine[x + 1] = currentLine[x + 2] = (byte)max;
|
||||
}
|
||||
});
|
||||
inputBitmap.UnlockBits(bitmapData);
|
||||
}
|
||||
return inputBitmap;
|
||||
}
|
||||
```
|
||||
|
||||
Les performances n'ont pas beaucoup augmenté mais au moins comme ca c'est fait
|
||||
Reference in New Issue
Block a user