usingSystem;usingSystem.Collections.Generic;usingSystem.Diagnostics;usingSystem.IO;namespaceBenchmarkCopyArray
{classProgram
{private const int TestTimes = 10000000;static voidMain()
{var testArrayCopy = newTestArrayCopy();
TestCopy(testArrayCopy.TestBinaryReader,"Binary.ReadBytes");
TestCopy(testArrayCopy.TestConvertToList,"ConvertToList");
TestCopy(testArrayCopy.TestArrayDotCopy,"Array.Copy");
TestCopy(testArrayCopy.TestBlockCopy,"Buffer.BlockCopy");
Console.Read();
}private static void TestCopy(Action testMethod, stringmethodName)
{var stopWatch = newStopwatch();
stopWatch.Start();for (int i = 0; i < TestTimes; i++)
{
testMethod();
}
testMethod();
stopWatch.Stop();
Console.WriteLine("{0}: {1} seconds, {2}.", methodName, stop