Skip to content

Commit

Permalink
Make benchmarks return size not save images
Browse files Browse the repository at this point in the history
  • Loading branch information
tocsoft committed Dec 19, 2016
1 parent 0fa3c13 commit 800af5f
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ namespace ImageSharp.Benchmarks
using CoreImage = ImageSharp.Image;
using CoreRectangle = ImageSharp.Rectangle;
using CoreColor = ImageSharp.Color;
using CoreSize = ImageSharp.Size;
using System.IO;
using System.Numerics;

public class FillRectangle
{
[Benchmark(Baseline = true, Description = "System.Drawing Fill Rectangle")]
public void FillRectangleSystemDrawing()
public Size FillRectangleSystemDrawing()
{
using (Bitmap destination = new Bitmap(800, 800))
{
Expand All @@ -30,29 +31,22 @@ public void FillRectangleSystemDrawing()
var pen = new Pen(Color.HotPink, 10);
graphics.FillRectangle(Brushes.HotPink, new Rectangle(10, 10, 190, 140));
}

using (MemoryStream ms = new MemoryStream())
{
destination.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
}
return destination.Size;
}
}

[Benchmark(Description = "ImageSharp Fill Rectangle")]
public void FillRactangleCore()
public CoreSize FillRactangleCore()
{
CoreImage image = new CoreImage(800, 800);

image.Fill(CoreColor.HotPink, new ImageSharp.Drawing.Shapes.RectangularPolygon(new CoreRectangle(10, 10, 190, 140)));

using (MemoryStream ms = new MemoryStream())
{
image.SaveAsBmp(ms);
}
return new CoreSize(image.Width, image.Height);
}

[Benchmark(Description = "ImageSharp Fill Rectangle - As Polygon")]
public void FillPolygonCore()
public CoreSize FillPolygonCore()
{
CoreImage image = new CoreImage(800, 800);

Expand All @@ -62,10 +56,7 @@ public void FillPolygonCore()
new Vector2(200, 150),
new Vector2(10, 150) });

using (MemoryStream ms = new MemoryStream())
{
image.SaveAsBmp(ms);
}
return new CoreSize(image.Width, image.Height);
}
}
}

0 comments on commit 800af5f

Please sign in to comment.