mirror of https://github.com/SixLabors/ImageSharp
Browse Source
in BulkConvertByteToNormalizedFloat() and BulkConvertNormalizedFloatToByteClampOverflows()af/merge-core
15 changed files with 406 additions and 272 deletions
@ -1,9 +1,9 @@ |
|||
namespace SixLabors.ImageSharp.Benchmarks.General |
|||
{ |
|||
using System; |
|||
using System; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.BasicMath |
|||
{ |
|||
public class Abs |
|||
{ |
|||
[Params(-1, 1)] |
|||
@ -0,0 +1,23 @@ |
|||
using BenchmarkDotNet.Attributes; |
|||
using BenchmarkDotNet.Attributes.Jobs; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.BasicMath |
|||
{ |
|||
[LongRunJob] |
|||
public class ModuloPowerOfTwoConstant |
|||
{ |
|||
private readonly int value = 42; |
|||
|
|||
[Benchmark(Baseline = true)] |
|||
public int Standard() |
|||
{ |
|||
return this.value % 8; |
|||
} |
|||
|
|||
[Benchmark] |
|||
public int Bitwise() |
|||
{ |
|||
return ImageMaths.Modulo8(this.value); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using BenchmarkDotNet.Attributes; |
|||
using BenchmarkDotNet.Attributes.Jobs; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.BasicMath |
|||
{ |
|||
[LongRunJob] |
|||
public class ModuloPowerOfTwoVariable |
|||
{ |
|||
private readonly int value = 42; |
|||
|
|||
private readonly int m = 32; |
|||
|
|||
[Benchmark(Baseline = true)] |
|||
public int Standard() |
|||
{ |
|||
return this.value % this.m; |
|||
} |
|||
|
|||
[Benchmark] |
|||
public int Bitwise() |
|||
{ |
|||
return ImageMaths.ModuloP2(this.value, this.m); |
|||
} |
|||
|
|||
// RESULTS:
|
|||
//
|
|||
// Method | Mean | Error | StdDev | Median | Scaled | ScaledSD |
|
|||
// --------- |----------:|----------:|----------:|----------:|-------:|---------:|
|
|||
// Standard | 1.2465 ns | 0.0093 ns | 0.0455 ns | 1.2423 ns | 1.00 | 0.00 |
|
|||
// Bitwise | 0.0265 ns | 0.0103 ns | 0.0515 ns | 0.0000 ns | 0.02 | 0.04 |
|
|||
} |
|||
} |
|||
@ -1,7 +1,8 @@ |
|||
using System; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General |
|||
namespace SixLabors.ImageSharp.Benchmarks.General.BasicMath |
|||
{ |
|||
public class Pow |
|||
{ |
|||
@ -1,19 +0,0 @@ |
|||
namespace SixLabors.ImageSharp.Benchmarks.General |
|||
{ |
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
public class Modulus |
|||
{ |
|||
[Benchmark(Baseline = true, Description = "Standard Modulus using %")] |
|||
public int StandardModulus() |
|||
{ |
|||
return 255 % 256; |
|||
} |
|||
|
|||
[Benchmark(Description = "Bitwise Modulus using &")] |
|||
public int BitwiseModulus() |
|||
{ |
|||
return 255 & 255; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue