Skip to content

Instantly share code, notes, and snippets.

@kleisauke
Last active July 31, 2019 07:53
Show Gist options
  • Save kleisauke/879e3075a675c6f945dff3772d2ef0a3 to your computer and use it in GitHub Desktop.
Save kleisauke/879e3075a675c6f945dff3772d2ef0a3 to your computer and use it in GitHub Desktop.
namespace Benchmark
{
using BenchmarkDotNet.Attributes;
using NetVips;
[Config(typeof(Config))]
public class Benchmark
{
[Benchmark(Description = "NetVips", Baseline = true)]
[Arguments("x.jpg", "x.png", 0)]
[Arguments("x.jpg", "x.png", 1)]
[Arguments("x.jpg", "x.png", 2)]
[Arguments("x.jpg", "x.png", 3)]
[Arguments("x.jpg", "x.png", 4)]
[Arguments("x.jpg", "x.png", 5)]
[Arguments("x.jpg", "x.png", 6)]
[Arguments("x.jpg", "x.png", 7)]
[Arguments("x.jpg", "x.png", 8)]
[Arguments("x.jpg", "x.png", 9)]
public void NetVips(string input, string output, int compression)
{
// input = https://commons.wikimedia.org/wiki/File:Stream_near_a_white_mountain_(Unsplash).jpg (4,000 x 5,000 pixels - 4.98 MB)
var im = Image.NewFromFile(input, access: Enums.Access.Sequential);
im.WriteToFile(output, new VOption
{
{"strip", true},
{"compression", compression}
});
}
}
}
BenchmarkDotNet=v0.11.5, OS=Windows 10.0.18362
Intel Core i5-8600K CPU 3.60GHz (Coffee Lake), 1 CPU, 6 logical and 6 physical cores
.NET Core SDK=2.2.401
  [Host]     : .NET Core 2.2.6 (CoreCLR 4.6.27817.03, CoreFX 4.6.27818.02), 64bit RyuJIT
  Job-OCCHPR : .NET Core 2.2.6 (CoreCLR 4.6.27817.03, CoreFX 4.6.27818.02), 64bit RyuJIT

Toolchain=.NET Core 2.2.0  
Method input output compression Mean Error StdDev Ratio
NetVips x.jpg x.png 0 863.6 ms 15.176 ms 16.868 ms 1.00
NetVips x.jpg x.png 1 1,082.4 ms 14.518 ms 12.870 ms 1.00
NetVips x.jpg x.png 2 1,553.4 ms 10.740 ms 10.046 ms 1.00
NetVips x.jpg x.png 3 1,849.4 ms 6.130 ms 5.119 ms 1.00
NetVips x.jpg x.png 4 1,788.3 ms 6.058 ms 5.370 ms 1.00
NetVips x.jpg x.png 5 2,196.3 ms 8.231 ms 7.699 ms 1.00
NetVips x.jpg x.png 6 3,307.7 ms 54.311 ms 50.803 ms 1.00
NetVips x.jpg x.png 7 6,455.8 ms 25.202 ms 23.574 ms 1.00
NetVips x.jpg x.png 8 12,437.0 ms 40.883 ms 38.242 ms 1.00
NetVips x.jpg x.png 9 13,759.6 ms 33.855 ms 31.668 ms 1.00
BenchmarkDotNet=v0.11.5, OS=Windows 10.0.18362
Intel Core i5-8600K CPU 3.60GHz (Coffee Lake), 1 CPU, 6 logical and 6 physical cores
.NET Core SDK=2.2.401
  [Host]     : .NET Core 2.2.6 (CoreCLR 4.6.27817.03, CoreFX 4.6.27818.02), 64bit RyuJIT
  Job-FMAPFI : .NET Core 2.2.6 (CoreCLR 4.6.27817.03, CoreFX 4.6.27818.02), 64bit RyuJIT

Toolchain=.NET Core 2.2.0  
Method input output compression Mean Error StdDev Ratio
NetVips x.jpg x.png 0 915.9 ms 18.119 ms 20.140 ms 1.00
NetVips x.jpg x.png 1 1,617.2 ms 7.912 ms 6.607 ms 1.00
NetVips x.jpg x.png 2 1,742.9 ms 7.154 ms 6.692 ms 1.00
NetVips x.jpg x.png 3 2,249.9 ms 7.621 ms 7.129 ms 1.00
NetVips x.jpg x.png 4 2,606.6 ms 16.200 ms 15.154 ms 1.00
NetVips x.jpg x.png 5 3,453.1 ms 8.956 ms 7.479 ms 1.00
NetVips x.jpg x.png 6 5,728.7 ms 21.255 ms 18.842 ms 1.00
NetVips x.jpg x.png 7 7,525.6 ms 132.807 ms 110.900 ms 1.00
NetVips x.jpg x.png 8 15,225.9 ms 317.596 ms 401.658 ms 1.00
NetVips x.jpg x.png 9 16,940.5 ms 337.410 ms 331.381 ms 1.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment