mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Fix issue #321 Former-commit-id: 9e975d942c48badeffa623cedfb5740645e4fd42 Former-commit-id: 30d157147ef9038228b2e283531ab383fdb4813d Former-commit-id: 7c32b6c8b267e02c6e9f5cde9a2a2da2330e8971af/merge-core
9 changed files with 129 additions and 47 deletions
@ -0,0 +1,22 @@ |
|||
namespace ImageProcessorCore.Benchmarks |
|||
{ |
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using CoreColor = ImageProcessorCore.Color; |
|||
using SystemColor = System.Drawing.Color; |
|||
|
|||
public class ColorEquality |
|||
{ |
|||
[Benchmark(Baseline = true, Description = "System.Drawing Color Equals")] |
|||
public bool SystemDrawingColorEqual() |
|||
{ |
|||
return SystemColor.FromArgb(128, 128, 128, 128).Equals(SystemColor.FromArgb(128, 128, 128, 128)); |
|||
} |
|||
|
|||
[Benchmark(Description = "ImageProcessorCore Color Equals")] |
|||
public bool ColorEqual() |
|||
{ |
|||
return new CoreColor(.5f, .5f, .5f, .5f).Equals(new CoreColor(.5f, .5f, .5f, .5f)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
namespace ImageProcessorCore.Benchmarks |
|||
{ |
|||
using System.Drawing; |
|||
|
|||
using CoreColor = ImageProcessorCore.Color; |
|||
|
|||
public class Colors |
|||
{ |
|||
[Benchmark(Baseline = true, Description = "System.Drawing Color")] |
|||
public bool SystemDrawingColorEqual() |
|||
{ |
|||
return Color.FromArgb(128, 128, 128, 128).Equals(Color.FromArgb(128, 128, 128, 128)); |
|||
} |
|||
|
|||
[Benchmark(Description = "ImageProcessorCore Color")] |
|||
public bool ColorEqual() |
|||
{ |
|||
return new CoreColor(.5f, .5f, .5f, .5f).Equals(new CoreColor(.5f, .5f, .5f, .5f)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
namespace ImageProcessorCore.Benchmarks.Image |
|||
{ |
|||
using System.Drawing; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using CoreColor = ImageProcessorCore.Color; |
|||
using CoreImage = ImageProcessorCore.Image; |
|||
using SystemColor = System.Drawing.Color; |
|||
|
|||
public class GetSetPixel |
|||
{ |
|||
[Benchmark(Baseline = true, Description = "System.Drawing GetSet Pixel")] |
|||
public SystemColor ResizeSystemDrawing() |
|||
{ |
|||
using (Bitmap source = new Bitmap(400, 400)) |
|||
{ |
|||
source.SetPixel(200, 200, SystemColor.White); |
|||
return source.GetPixel(200, 200); |
|||
} |
|||
} |
|||
|
|||
[Benchmark(Description = "ImageProcessorCore GetSet Pixel")] |
|||
public CoreColor ResizeCore() |
|||
{ |
|||
using (CoreImage image = new CoreImage(400, 400)) |
|||
{ |
|||
image[200, 200] = CoreColor.White; |
|||
return image[200, 200]; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
namespace ImageProcessorCore.Benchmarks |
|||
{ |
|||
using System.Drawing; |
|||
using System.Drawing.Drawing2D; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using ImageProcessorCore.Samplers; |
|||
using CoreImage = ImageProcessorCore.Image; |
|||
using CoreSize = ImageProcessorCore.Size; |
|||
|
|||
public class Crop |
|||
{ |
|||
[Benchmark(Baseline = true, Description = "System.Drawing Crop")] |
|||
public Size CropSystemDrawing() |
|||
{ |
|||
using (Bitmap source = new Bitmap(400, 400)) |
|||
{ |
|||
using (Bitmap destination = new Bitmap(100, 100)) |
|||
{ |
|||
using (Graphics graphics = Graphics.FromImage(destination)) |
|||
{ |
|||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; |
|||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; |
|||
graphics.CompositingQuality = CompositingQuality.HighQuality; |
|||
graphics.DrawImage(source, new Rectangle(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); |
|||
} |
|||
|
|||
return destination.Size; |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Benchmark(Description = "ImageProcessorCore Crop")] |
|||
public CoreSize CropResizeCore() |
|||
{ |
|||
using (CoreImage image = new CoreImage(400, 400)) |
|||
{ |
|||
image.Crop(100, 100); |
|||
return new CoreSize(image.Width, image.Height); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue