Browse Source

Add more throughput benchmarks and pass Configuration where missed (#3114)

* Add GaussianBlur throughput benchmark and pass Configuration where missed

* also add `-m EdgesCompass`
pull/2899/merge
Anton Firszov 1 month ago
committed by GitHub
parent
commit
988314aae7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 27
      tests/ImageSharp.Tests.ProfilingSandbox/ProcessorThroughputBenchmark.cs

27
tests/ImageSharp.Tests.ProfilingSandbox/ProcessorThroughputBenchmark.cs

@ -6,6 +6,7 @@ using CommandLine;
using CommandLine.Text; using CommandLine.Text;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Convolution;
namespace SixLabors.ImageSharp.Tests.ProfilingSandbox; namespace SixLabors.ImageSharp.Tests.ProfilingSandbox;
@ -49,10 +50,12 @@ public sealed class ProcessorThroughputBenchmark
{ {
Method.Crop => this.Crop, Method.Crop => this.Crop,
Method.Edges => this.DetectEdges, Method.Edges => this.DetectEdges,
Method.EdgesCompass => this.EdgesCompass,
Method.DrawImage => this.DrawImage, Method.DrawImage => this.DrawImage,
Method.BinaryThreshold => this.BinaryThreshold, Method.BinaryThreshold => this.BinaryThreshold,
Method.Histogram => this.Histogram, Method.Histogram => this.Histogram,
Method.OilPaint => this.OilPaint, Method.OilPaint => this.OilPaint,
Method.GaussianBlur => this.GaussianBlur,
_ => throw new NotImplementedException(), _ => throw new NotImplementedException(),
}; };
@ -138,6 +141,13 @@ public sealed class ProcessorThroughputBenchmark
return image.Width * image.Height; return image.Width * image.Height;
} }
private int EdgesCompass()
{
using Image<Rgba32> image = new(this.options.Width, this.options.Height);
image.Mutate(this.configuration, x => x.DetectEdges(EdgeDetectorCompassKernel.Kirsch));
return image.Width * image.Height;
}
private int Crop() private int Crop()
{ {
using Image<Rgba32> image = new(this.options.Width, this.options.Height); using Image<Rgba32> image = new(this.options.Width, this.options.Height);
@ -151,32 +161,41 @@ public sealed class ProcessorThroughputBenchmark
{ {
using Image<Rgba32> image = new(this.options.Width, this.options.Height); using Image<Rgba32> image = new(this.options.Width, this.options.Height);
using Image<Rgba32> foreground = new(this.options.Width, this.options.Height); using Image<Rgba32> foreground = new(this.options.Width, this.options.Height);
image.Mutate(c => c.DrawImage(foreground, 0.5f)); image.Mutate(this.configuration, c => c.DrawImage(foreground, 0.5f));
return image.Width * image.Height; return image.Width * image.Height;
} }
private int BinaryThreshold() private int BinaryThreshold()
{ {
using Image<Rgba32> image = new(this.options.Width, this.options.Height); using Image<Rgba32> image = new(this.options.Width, this.options.Height);
image.Mutate(c => c.BinaryThreshold(0.5f)); image.Mutate(this.configuration, c => c.BinaryThreshold(0.5f));
return image.Width * image.Height; return image.Width * image.Height;
} }
private int Histogram() private int Histogram()
{ {
using Image<Rgba32> image = new(this.options.Width, this.options.Height); using Image<Rgba32> image = new(this.options.Width, this.options.Height);
image.Mutate(c => c.HistogramEqualization()); image.Mutate(this.configuration, c => c.HistogramEqualization());
return image.Width * image.Height;
}
private int GaussianBlur()
{
using Image<Rgba32> image = new(this.options.Width, this.options.Height);
image.Mutate(this.configuration, c => c.GaussianBlur());
return image.Width * image.Height; return image.Width * image.Height;
} }
private enum Method private enum Method
{ {
Edges, Edges,
EdgesCompass,
Crop, Crop,
DrawImage, DrawImage,
BinaryThreshold, BinaryThreshold,
Histogram, Histogram,
OilPaint OilPaint,
GaussianBlur,
} }
private sealed class CommandLineOptions private sealed class CommandLineOptions

Loading…
Cancel
Save