From ce4d4bfb1a75cc0e2dc30d69d81f23dd7811b556 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 21 Dec 2017 09:33:19 +1100 Subject: [PATCH] Update Colorful and add Pow benchmark --- tests/ImageSharp.Benchmarks/General/Pow.cs | 40 +++++++++++++++++++ .../ImageSharp.Benchmarks.csproj | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/ImageSharp.Benchmarks/General/Pow.cs diff --git a/tests/ImageSharp.Benchmarks/General/Pow.cs b/tests/ImageSharp.Benchmarks/General/Pow.cs new file mode 100644 index 0000000000..325bd9d20e --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Pow.cs @@ -0,0 +1,40 @@ +using System; +using BenchmarkDotNet.Attributes; + +namespace SixLabors.ImageSharp.Benchmarks.General +{ + public class Pow + { + [Params(-1.333F, 1.333F)] + public float X { get; set; } + + + [Benchmark(Baseline = true, Description = "Math.Pow 2")] + public float MathPow() + { + float x = this.X; + return (float)Math.Pow(x, 2); + } + + [Benchmark(Description = "Pow x2")] + public float PowMult() + { + float x = this.X; + return x * x; + } + + [Benchmark(Description = "Math.Pow 3")] + public float MathPow3() + { + float x = this.X; + return (float)Math.Pow(x, 3); + } + + [Benchmark(Description = "Pow x3")] + public float PowMult3() + { + float x = this.X; + return x * x * x; + } + } +} diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 417e849be1..bf546c91b1 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -15,7 +15,7 @@ - +