Skip to content

Instantly share code, notes, and snippets.

@mattleibow
Created July 31, 2020 09:37
Show Gist options
  • Save mattleibow/ae4dc0213123a73fe199703cc4591f52 to your computer and use it in GitHub Desktop.
Save mattleibow/ae4dc0213123a73fe199703cc4591f52 to your computer and use it in GitHub Desktop.
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
namespace SkiaSharp.Benchmarks
{
//[SimpleJob(RuntimeMoniker.CoreRt31)]
[SimpleJob(RuntimeMoniker.Mono)]
[SimpleJob(RuntimeMoniker.Net472)]
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
public class Benchmark
{
private SKPath path;
private SKBitmap bitmap;
private SKCanvas canvas;
private SKPaint paint;
public Benchmark()
{
path = SKPath.ParseSvgPathData("M150 0 L75 200 L225 200 Z");
bitmap = new SKBitmap(500, 500);
canvas = new SKCanvas(bitmap);
paint = new SKPaint
{
IsAntialias = true,
Color = SKColors.Red
};
}
[Benchmark]
public void DrawPath()
{
canvas.Save();
canvas.DrawPath(path, paint);
canvas.Restore();
}
[Benchmark]
public void ClipDrawPaint()
{
canvas.Save();
canvas.ClipPath(path);
canvas.DrawPaint(paint);
canvas.Restore();
}
}
public class Program
{
public static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<Benchmark>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment