Browse Source

Better benchmarks for ToVector4()

proving that the current API is fine
pull/744/head
Anton Firszov 8 years ago
parent
commit
6289a87e6d
  1. 8
      tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs
  2. 8
      tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs
  3. 9
      tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs

8
tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs

@ -75,9 +75,9 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion
} }
// RESULTS: // RESULTS:
// Method | Count | Mean | Error | StdDev | Scaled | // Method | Count | Mean | Error | StdDev | Scaled |
// ---------- |------ |---------:|----------:|----------:|-------:| // ---------- |------ |---------:|---------:|---------:|-------:|
// UseRetval | 32 | 94.99 ns | 1.1199 ns | 0.9352 ns | 1.00 | // UseRetval | 32 | 109.0 ns | 1.202 ns | 1.125 ns | 1.00 |
// UseCopyTo | 32 | 59.47 ns | 0.6104 ns | 0.5710 ns | 0.63 | // UseCopyTo | 32 | 108.6 ns | 1.151 ns | 1.020 ns | 1.00 |
} }
} }

8
tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs

@ -87,9 +87,9 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion
} }
// RESULTS: // RESULTS:
// Method | Count | Mean | Error | StdDev | Scaled | // Method | Count | Mean | Error | StdDev | Scaled | ScaledSD |
// ---------- |------ |----------:|----------:|----------:|-------:| // ---------- |------ |---------:|---------:|---------:|-------:|---------:|
// UseRetval | 32 | 100.35 ns | 0.4844 ns | 0.4532 ns | 1.00 | // UseRetval | 32 | 120.2 ns | 1.560 ns | 1.383 ns | 1.00 | 0.00 |
// UseCopyTo | 32 | 53.95 ns | 0.1269 ns | 0.1125 ns | 0.54 | // UseCopyTo | 32 | 121.7 ns | 2.439 ns | 2.281 ns | 1.01 | 0.02 |
} }
} }

9
tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs

@ -57,16 +57,15 @@ namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector4 ToVector4() public Vector4 ToVector4()
{ {
return new Vector4(this.r, this.g, this.b, this.a); return new Vector4(this.r, this.g, this.b, this.a) * new Vector4(1f / 255f);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void CopyToVector4(ref Vector4 dest) public void CopyToVector4(ref Vector4 dest)
{ {
dest.X = this.r; var tmp = new Vector4(this.r, this.g, this.b, this.a);
dest.Y = this.g; tmp *= new Vector4(1f / 255f);
dest.Z = this.b; dest = tmp;
dest.W = this.a;
} }
} }
} }
Loading…
Cancel
Save