Commits

igor  committed cffbddf

Added perf. tests for byte array copying.

  • Participants
  • Parent commits 1add6a9

Comments (0)

Files changed (4)

File Projects/WeAreCollections/WeAreCollections/Program.cs

             //tests.Add(new SortedSetAddingUniqueTest());
             //tests.Add(new SortedDictionaryAddingUniqueTest());
             //tests.Add(new SortedListAddingUniqueTest());
-            tests.Add(new HeapAddingUniqueTest());
+            //tests.Add(new HeapAddingUniqueTest());
+            tests.Add(new BufferBlockCopyTest());
+            tests.Add(new ArrayCopyTest());
+            tests.Add(new BufferBlockCopyTest());
 
             ExecuteTests(tests);
         }

File Projects/WeAreCollections/WeAreCollections/Tests/ArrayCopyTest.cs

+using System;
+
+namespace WeAreCollections.Tests
+{
+    public class ArrayCopyTest : IPerformanceTest
+    {
+        public int SuggestedTestStepsCount
+        {
+            get { return 100000; }
+        }
+
+        public string GetTestDescription(int expectedTestStepsCount)
+        {
+            return "Array.Copy() between two byte arrays";
+        }
+
+        public void Initialize(Random rnd, int expectedTestStepsCount)
+        {
+            source = new byte[100000];
+            dest = new byte[120000];
+        }
+
+        public void ExecuteStep(int step)
+        {
+            Array.Copy(source, 0, dest, 10000, 100000);
+        }
+
+        public void AssertValidity()
+        {
+        }
+
+        private byte[] source;
+        private byte[] dest;
+    }
+}

File Projects/WeAreCollections/WeAreCollections/Tests/BufferBlockCopyTest.cs

+using System;
+
+namespace WeAreCollections.Tests
+{
+    public class BufferBlockCopyTest : IPerformanceTest
+    {
+        public int SuggestedTestStepsCount
+        {
+            get { return 100000; }
+        }
+
+        public string GetTestDescription(int expectedTestStepsCount)
+        {
+            return "Buffer.BlockCopy() between two byte arrays";
+        }
+
+        public void Initialize(Random rnd, int expectedTestStepsCount)
+        {
+            source = new byte[100000];
+            dest = new byte[120000];
+        }
+
+        public void ExecuteStep(int step)
+        {
+            Buffer.BlockCopy(source, 0, dest, 10000, 100000);
+        }
+
+        public void AssertValidity()
+        {
+        }
+
+        private byte[] source;
+        private byte[] dest;
+    }
+}

File Projects/WeAreCollections/WeAreCollections/WeAreCollections.csproj

     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="TestHelper.cs" />
+    <Compile Include="Tests\ArrayCopyTest.cs" />
+    <Compile Include="Tests\BufferBlockCopyTest.cs" />
     <Compile Include="Tests\HeapAddingUniqueTest.cs" />
     <Compile Include="Tests\SortedDictionaryAddingUniqueTest.cs" />
     <Compile Include="Tests\SortedListAddingUniqueTest.cs" />