📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
799 B

using System;
using System.Runtime.CompilerServices;
namespace ImageProcessorCore.Benchmarks.General
{
using BenchmarkDotNet.Attributes;
public class ArrayCopy
{
private double[] source = new double[10000];
[Benchmark(Baseline = true, Description = "Copy using Array.Copy()")]
public double CopyArray()
{
double[] destination = new double[10000];
Array.Copy(source, destination, 10000);
return destination[0];
}
[Benchmark(Description = "Copy using Unsafe<T>")]
public unsafe double CopyUnsafe()
{
double[] destination = new double[10000];
Unsafe.Copy(Unsafe.AsPointer(ref destination), ref source);
return destination[0];
}
}
}