Browse Source

fix Benchmarks project

pull/607/head
Anton Firszov 8 years ago
parent
commit
8af0df92ff
  1. 8
      tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs
  2. 8
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs
  3. 8
      tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs
  4. 8
      tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs
  5. 2
      tests/ImageSharp.Benchmarks/Samplers/Glow.cs

8
tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs

@ -36,8 +36,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark(Baseline = true)] [Benchmark(Baseline = true)]
public void PerElement() public void PerElement()
{ {
Span<TPixel> s = this.source.Span; Span<TPixel> s = this.source.GetSpan();
Span<Vector4> d = this.destination.Span; Span<Vector4> d = this.destination.GetSpan();
for (int i = 0; i < this.Count; i++) for (int i = 0; i < this.Count; i++)
{ {
@ -49,13 +49,13 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark] [Benchmark]
public void CommonBulk() public void CommonBulk()
{ {
new PixelOperations<TPixel>().ToVector4(this.source.Span, this.destination.Span, this.Count); new PixelOperations<TPixel>().ToVector4(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
} }
[Benchmark] [Benchmark]
public void OptimizedBulk() public void OptimizedBulk()
{ {
PixelOperations<TPixel>.Instance.ToVector4(this.source.Span, this.destination.Span, this.Count); PixelOperations<TPixel>.Instance.ToVector4(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
} }
} }

8
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs

@ -36,8 +36,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark(Baseline = true)] [Benchmark(Baseline = true)]
public void PerElement() public void PerElement()
{ {
Span<TPixel> s = this.source.Span; Span<TPixel> s = this.source.GetSpan();
Span<byte> d = this.destination.Span; Span<byte> d = this.destination.GetSpan();
var rgb = default(Rgb24); var rgb = default(Rgb24);
@ -55,13 +55,13 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark] [Benchmark]
public void CommonBulk() public void CommonBulk()
{ {
new PixelOperations<TPixel>().ToRgb24Bytes(this.source.Span, this.destination.Span, this.Count); new PixelOperations<TPixel>().ToRgb24Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
} }
[Benchmark] [Benchmark]
public void OptimizedBulk() public void OptimizedBulk()
{ {
PixelOperations<TPixel>.Instance.ToRgb24Bytes(this.source.Span, this.destination.Span, this.Count); PixelOperations<TPixel>.Instance.ToRgb24Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
} }
} }

8
tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs

@ -38,8 +38,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark(Baseline = true)] [Benchmark(Baseline = true)]
public void PerElement() public void PerElement()
{ {
Span<TPixel> s = this.source.Span; Span<TPixel> s = this.source.GetSpan();
Span<byte> d = this.destination.Span; Span<byte> d = this.destination.GetSpan();
var rgba = default(Rgba32); var rgba = default(Rgba32);
@ -58,13 +58,13 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk
[Benchmark] [Benchmark]
public void CommonBulk() public void CommonBulk()
{ {
new PixelOperations<TPixel>().ToRgba32Bytes(this.source.Span, this.destination.Span, this.Count); new PixelOperations<TPixel>().ToRgba32Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
} }
[Benchmark] [Benchmark]
public void OptimizedBulk() public void OptimizedBulk()
{ {
PixelOperations<TPixel>.Instance.ToRgba32Bytes(this.source.Span, this.destination.Span, this.Count); PixelOperations<TPixel>.Instance.ToRgba32Bytes(this.source.GetSpan(), this.destination.GetSpan(), this.Count);
} }
} }

8
tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs

@ -61,14 +61,14 @@ namespace SixLabors.ImageSharp.Benchmarks
{ {
using (IBuffer<float> amounts = Configuration.Default.MemoryAllocator.Allocate<float>(image.Width)) using (IBuffer<float> amounts = Configuration.Default.MemoryAllocator.Allocate<float>(image.Width))
{ {
amounts.Span.Fill(1); amounts.GetSpan().Fill(1);
using (PixelAccessor<Rgba32> pixels = image.Lock()) using (PixelAccessor<Rgba32> pixels = image.Lock())
{ {
for (int y = 0; y < image.Height; y++) for (int y = 0; y < image.Height; y++)
{ {
Span<Rgba32> span = pixels.GetRowSpan(y); Span<Rgba32> span = pixels.GetRowSpan(y);
this.BulkVectorConvert(span, span, span, amounts.Span); this.BulkVectorConvert(span, span, span, amounts.GetSpan());
} }
} }
return new CoreSize(image.Width, image.Height); return new CoreSize(image.Width, image.Height);
@ -83,13 +83,13 @@ namespace SixLabors.ImageSharp.Benchmarks
{ {
using (IBuffer<float> amounts = Configuration.Default.MemoryAllocator.Allocate<float>(image.Width)) using (IBuffer<float> amounts = Configuration.Default.MemoryAllocator.Allocate<float>(image.Width))
{ {
amounts.Span.Fill(1); amounts.GetSpan().Fill(1);
using (PixelAccessor<Rgba32> pixels = image.Lock()) using (PixelAccessor<Rgba32> pixels = image.Lock())
{ {
for (int y = 0; y < image.Height; y++) for (int y = 0; y < image.Height; y++)
{ {
Span<Rgba32> span = pixels.GetRowSpan(y); Span<Rgba32> span = pixels.GetRowSpan(y);
this.BulkPixelConvert(span, span, span, amounts.Span); this.BulkPixelConvert(span, span, span, amounts.GetSpan());
} }
} }

2
tests/ImageSharp.Benchmarks/Samplers/Glow.cs

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using (IBuffer<TPixel> rowColors = Configuration.Default.MemoryAllocator.Allocate<TPixel>(width)) using (IBuffer<TPixel> rowColors = Configuration.Default.MemoryAllocator.Allocate<TPixel>(width))
using (PixelAccessor<TPixel> sourcePixels = source.Lock()) using (PixelAccessor<TPixel> sourcePixels = source.Lock())
{ {
rowColors.Span.Fill(glowColor); rowColors.GetSpan().Fill(glowColor);
Parallel.For( Parallel.For(
minY, minY,

Loading…
Cancel
Save