static void TestHelper(int itemsCount) { var countBenchmark = new CountBenchmark(); countBenchmark.ItemsCount = itemsCount; countBenchmark.GlobalSetup(); int naive = countBenchmark.Naive(); Assert.AreEqual(naive, countBenchmark.LINQ()); Assert.AreEqual(naive, countBenchmark.Vectors()); #if NETCOREAPP3_0 Assert.AreEqual(naive, countBenchmark.Intrinsics()); #endif }
public void HardTest() { var countBenchmark = new CountBenchmark(); const int count = 1000000; countBenchmark.ItemsCount = count; countBenchmark.GlobalSetup(); for (int i = 0; i < countBenchmark.ItemsCount; i += 8) { for (int j = 0; j < 8; j++) { countBenchmark.Array[i + j] = 0; } countBenchmark.Array[i + 5] = 31337; countBenchmark.Array[i + 3] = 31337; } countBenchmark.Item = 31337; Assert.AreEqual(250000, countBenchmark.Naive()); Assert.AreEqual(250000, countBenchmark.LINQ()); Assert.AreEqual(250000, countBenchmark.Vectors()); #if NETCOREAPP3_0 Assert.AreEqual(250000, countBenchmark.Intrinsics()); #endif }