Created
May 31, 2017 09:04
-
-
Save AlleSchonWeg/605fdb08d4185cd248a690edb07cd856 to your computer and use it in GitHub Desktop.
SimplePerfTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} | |
} |
Author
AlleSchonWeg
commented
Jun 6, 2017
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