mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Former-commit-id: 3ebb26faca837aeac974a67da676be409d902ae7 Former-commit-id: d7a8a733fabfb6621f8f3a04c56b9f2aa6913392 Former-commit-id: ec769799df83b3f7b1d4934aead8e6ae1e280736pull/1/head
4 changed files with 79 additions and 3 deletions
@ -0,0 +1,57 @@ |
|||
namespace ImageProcessorCore.Benchmarks.Image |
|||
{ |
|||
using System.Threading.Tasks; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using CoreColor = ImageProcessorCore.Color; |
|||
using CoreImage = ImageProcessorCore.Image; |
|||
|
|||
public class CopyPixels |
|||
{ |
|||
[Benchmark(Description = "Copy by Pixel")] |
|||
public CoreColor CopyByPixel() |
|||
{ |
|||
CoreImage source = new CoreImage(1024, 768); |
|||
CoreImage target = new CoreImage(1024, 768); |
|||
using (PixelAccessor<CoreColor, uint> sourcePixels = source.Lock()) |
|||
using (PixelAccessor<CoreColor, uint> targetPixels = target.Lock()) |
|||
{ |
|||
Parallel.For( |
|||
0, |
|||
source.Height, |
|||
Bootstrapper.Instance.ParallelOptions, |
|||
y => |
|||
{ |
|||
for (int x = 0; x < source.Width; x++) |
|||
{ |
|||
targetPixels[x, y] = sourcePixels[x, y]; |
|||
} |
|||
}); |
|||
|
|||
return targetPixels[0, 0]; |
|||
} |
|||
} |
|||
|
|||
[Benchmark(Description = "Copy by Row")] |
|||
public CoreColor CopyByRow() |
|||
{ |
|||
CoreImage source = new CoreImage(1024, 768); |
|||
CoreImage target = new CoreImage(1024, 768); |
|||
using (PixelAccessor<CoreColor, uint> sourcePixels = source.Lock()) |
|||
using (PixelAccessor<CoreColor, uint> targetPixels = target.Lock()) |
|||
{ |
|||
Parallel.For( |
|||
0, |
|||
source.Height, |
|||
Bootstrapper.Instance.ParallelOptions, |
|||
y => |
|||
{ |
|||
sourcePixels.CopyRow(0, y, targetPixels, 0, y, source.Width); |
|||
}); |
|||
|
|||
return targetPixels[0, 0]; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue