Skip to content

Instantly share code, notes, and snippets.

@AlleSchonWeg
Created May 31, 2017 09:04
Show Gist options
  • Save AlleSchonWeg/605fdb08d4185cd248a690edb07cd856 to your computer and use it in GitHub Desktop.
Save AlleSchonWeg/605fdb08d4185cd248a690edb07cd856 to your computer and use it in GitHub Desktop.
SimplePerfTest
using ImageSharp;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var sw = new Stopwatch();
for (int i = 0; i < 50; i++)
{
sw.Restart();
RenderGdi();
sw.Stop();
Console.WriteLine("GDI: " + sw.Elapsed);
sw.Restart();
RenderSharp();
sw.Stop();
Console.WriteLine("ImageSharp: " + sw.Elapsed);
Console.WriteLine();
}
Console.Read();
}
private static void RenderGdi()
{
using (var img = new Bitmap(400, 400))
{
using (var graphics = Graphics.FromImage(img))
{
graphics.Clear(Color.Black);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(img.Width / 2 - 50, img.Height / 2 - 25, 100, 50);
graphics.FillRectangle(Brushes.Red, rect);
}
}
}
private static void RenderSharp()
{
using (var img = new Image<Rgba32>(400, 400))
{
img.Fill(Rgba32.Black);
var sRect = new ImageSharp.Rectangle(img.Width / 2 - 50, img.Height / 2 - 25, 100, 50);
img.Fill(Rgba32.Red, sRect);
}
}
}
}
@AlleSchonWeg
Copy link
Author

BenchmarkDotNet=v0.10.6, OS=Windows 10 Redstone 1 (10.0.14393)
Processor=Intel Xeon CPU E5-2667 0 2.90GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
  [Host]     : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.6.1648.0
  DefaultJob : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.6.1648.0

Method Mean Error StdDev
RenderGdi 767.8 us 36.62 us 107.4 us
RenderSharp 12,655.2 us 238.32 us 199.0 us

@AlleSchonWeg
Copy link
Author

BenchmarkDotNet=v0.10.6, OS=Windows 10 Redstone 1 (10.0.14393)
Processor=Intel Xeon CPU E5-2667 0 2.90GHz, ProcessorCount=4
Frequency=10000000 Hz, Resolution=100.0000 ns, Timer=UNKNOWN
  [Host]     : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.7.2053.0
  DefaultJob : Clr 4.0.30319.42000, 32bit LegacyJIT-v4.7.2053.0

Method Mean Error StdDev Median
RenderGdi 821.2 us 40.64 us 119.18 us 820.2 us
RenderSharp 11,582.6 us 231.40 us 507.92 us 11,672.2 us
RenderSkia 537.4 us 20.81 us 61.05 us 554.0 us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment