From fbac57b24312435ac4f10671655eba3762814a46 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:47:35 +0100 Subject: [PATCH 01/45] remove System.Collections.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/f419bc3b47b7533303ac46e8c72284efe95acec3 --- .../System.Collections/System.Collections.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.BitArray.cs | 463 -------- .../tests/Performance/Perf.Dictionary.cs | 473 -------- .../tests/Performance/Perf.HashSet.cs | 554 --------- .../tests/Performance/Perf.List.cs | 1058 ----------------- ...System.Collections.PerformanceTests.csproj | 25 - 7 files changed, 2590 deletions(-) delete mode 100644 src/libraries/System.Collections/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Collections/tests/Performance/Perf.BitArray.cs delete mode 100644 src/libraries/System.Collections/tests/Performance/Perf.Dictionary.cs delete mode 100644 src/libraries/System.Collections/tests/Performance/Perf.HashSet.cs delete mode 100644 src/libraries/System.Collections/tests/Performance/Perf.List.cs delete mode 100644 src/libraries/System.Collections/tests/Performance/System.Collections.PerformanceTests.csproj diff --git a/src/libraries/System.Collections/System.Collections.sln b/src/libraries/System.Collections/System.Collections.sln index 655316c69a1aa..c71e69246d53c 100644 --- a/src/libraries/System.Collections/System.Collections.sln +++ b/src/libraries/System.Collections/System.Collections.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.Tests", {D5FF747F-7A0B-9003-885A-FE9A63E755E5} = {D5FF747F-7A0B-9003-885A-FE9A63E755E5} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.PerformanceTests", "tests\Performance\System.Collections.PerformanceTests.csproj", "{F2B47C9D-477E-4EB2-B7F9-D7563FCED117}" - ProjectSection(ProjectDependencies) = postProject - {D5FF747F-7A0B-9003-885A-FE9A63E755E5} = {D5FF747F-7A0B-9003-885A-FE9A63E755E5} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections", "src\System.Collections.csproj", "{D5FF747F-7A0B-9003-885A-FE9A63E755E5}" ProjectSection(ProjectDependencies) = postProject {C746D448-E7C3-4850-9CA7-D3F1FA49742F} = {C746D448-E7C3-4850-9CA7-D3F1FA49742F} @@ -35,10 +30,6 @@ Global {F5EB9630-AD29-4880-963F-F2D39C684D8A}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {F5EB9630-AD29-4880-963F-F2D39C684D8A}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {F5EB9630-AD29-4880-963F-F2D39C684D8A}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {F2B47C9D-477E-4EB2-B7F9-D7563FCED117}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {F2B47C9D-477E-4EB2-B7F9-D7563FCED117}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {F2B47C9D-477E-4EB2-B7F9-D7563FCED117}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {F2B47C9D-477E-4EB2-B7F9-D7563FCED117}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {D5FF747F-7A0B-9003-885A-FE9A63E755E5}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {D5FF747F-7A0B-9003-885A-FE9A63E755E5}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {D5FF747F-7A0B-9003-885A-FE9A63E755E5}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {F5EB9630-AD29-4880-963F-F2D39C684D8A} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {F2B47C9D-477E-4EB2-B7F9-D7563FCED117} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {D5FF747F-7A0B-9003-885A-FE9A63E755E5} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {C746D448-E7C3-4850-9CA7-D3F1FA49742F} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Collections/tests/Performance/Configurations.props b/src/libraries/System.Collections/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Collections/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Collections/tests/Performance/Perf.BitArray.cs b/src/libraries/System.Collections/tests/Performance/Perf.BitArray.cs deleted file mode 100644 index 44de078586c13..0000000000000 --- a/src/libraries/System.Collections/tests/Performance/Perf.BitArray.cs +++ /dev/null @@ -1,463 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Tests -{ - public class Perf_BitArray - { - const int IterationCount = 100_000; - - private static Random s_random = new Random(42); - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1, true)] - [InlineData(10, true)] - [InlineData(32, true)] - [InlineData(64, true)] - [InlineData(100, true)] - [InlineData(128, true)] - [InlineData(1000, true)] - [InlineData(1, false)] - [InlineData(10, false)] - [InlineData(32, false)] - [InlineData(64, false)] - [InlineData(100, false)] - [InlineData(128, false)] - [InlineData(1000, false)] - public void BitArrayLengthCtor(int size, bool value) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var local = new BitArray(size, value); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1, true)] - [InlineData(2, true)] - [InlineData(3, true)] - [InlineData(4, true)] - [InlineData(10, true)] - [InlineData(32, true)] - [InlineData(64, true)] - [InlineData(100, true)] - [InlineData(128, true)] - [InlineData(1000, true)] - [InlineData(1, false)] - [InlineData(2, false)] - [InlineData(3, false)] - [InlineData(4, false)] - [InlineData(10, false)] - [InlineData(32, false)] - [InlineData(64, false)] - [InlineData(100, false)] - [InlineData(128, false)] - [InlineData(1000, false)] - public void BitArrayBitArrayCtor(int size, bool value) - { - var original = new BitArray(size, value); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var local = new BitArray(original); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayBoolArrayCtor(int size) - { - var bools = new bool[size]; - - for (int i = 0; i < bools.Length; i++) - { - bools[i] = s_random.NextDouble() >= 0.5; - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var local = new BitArray(bools); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayByteArrayCtor(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var local = new BitArray(bytes); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayIntArrayCtor(int size) - { - var ints = new int[size]; - for (int i = 0; i < ints.Length; i++) - { - ints[i] = s_random.Next(); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var local = new BitArray(ints); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1, true)] - [InlineData(2, true)] - [InlineData(3, true)] - [InlineData(4, true)] - [InlineData(10, true)] - [InlineData(32, true)] - [InlineData(64, true)] - [InlineData(100, true)] - [InlineData(128, true)] - [InlineData(1000, true)] - [InlineData(1, false)] - [InlineData(2, false)] - [InlineData(3, false)] - [InlineData(4, false)] - [InlineData(10, false)] - [InlineData(32, false)] - [InlineData(64, false)] - [InlineData(100, false)] - [InlineData(128, false)] - [InlineData(1000, false)] - public void BitArraySetAll(int size, bool value) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - original.SetAll(value); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayNot(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - original.Not(); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayGet(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - bool local = false; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < original.Length; j++) - { - local ^= original.Get(j); - } - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArraySet(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - - var values = new bool[original.Length]; - for (int i = 0; i < values.Length; i++) - { - values[i] = s_random.NextDouble() >= 0.5; - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < original.Length; j++) - { - original.Set(j, values[j]); - } - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArraySetLengthGrow(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var original = new BitArray(bytes); - original.Length = original.Length * 2; - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArraySetLengthShrink(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - var original = new BitArray(bytes); - original.Length = original.Length / 2; - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayCopyToIntArray(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - - var array = new int[size * 32]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - original.CopyTo(array, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayCopyToByteArray(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - - var array = new byte[size * 32]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - original.CopyTo(array, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(10)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(128)] - [InlineData(1000)] - public void BitArrayCopyToBoolArray(int size) - { - var bytes = new byte[size]; - s_random.NextBytes(bytes); - var original = new BitArray(bytes); - - var array = new bool[size * 32]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - original.CopyTo(array, 0); - } - } - } - } - } -} diff --git a/src/libraries/System.Collections/tests/Performance/Perf.Dictionary.cs b/src/libraries/System.Collections/tests/Performance/Perf.Dictionary.cs deleted file mode 100644 index bbe5eabcb80e1..0000000000000 --- a/src/libraries/System.Collections/tests/Performance/Perf.Dictionary.cs +++ /dev/null @@ -1,473 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Tests -{ - public class Perf_Dictionary - { - /// - /// Creates a Dictionary of int-int with the specified number of pairs - /// - public static Dictionary CreateDictionary(int size) - { - Random rand = new Random(837322); - Dictionary dict = new Dictionary(); - while (dict.Count < size) - { - int key = rand.Next(500000, int.MaxValue); - dict.TryAdd(key, 0); - } - return dict; - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void Add(int size) - { - Dictionary dict = CreateDictionary(size); - foreach (var iteration in Benchmark.Iterations) - { - Dictionary copyDict = new Dictionary(dict); - using (iteration.StartMeasurement()) - for (int i = 0; i <= 20000; i++) - { - copyDict.Add(i * 10 + 1, 0); copyDict.Add(i * 10 + 2, 0); copyDict.Add(i * 10 + 3, 0); - copyDict.Add(i * 10 + 4, 0); copyDict.Add(i * 10 + 5, 0); copyDict.Add(i * 10 + 6, 0); - copyDict.Add(i * 10 + 7, 0); copyDict.Add(i * 10 + 8, 0); copyDict.Add(i * 10 + 9, 0); - } - } - } - - [Benchmark] - public void ctor() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i <= 20000; i++) - { - new Dictionary(); new Dictionary(); new Dictionary(); - new Dictionary(); new Dictionary(); new Dictionary(); - new Dictionary(); new Dictionary(); new Dictionary(); - } - } - - [Benchmark] - [InlineData(0)] - [InlineData(1024)] - [InlineData(4096)] - [InlineData(16384)] - public void ctor_int(int size) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i <= 500; i++) - { - new Dictionary(size); new Dictionary(size); new Dictionary(size); - new Dictionary(size); new Dictionary(size); new Dictionary(size); - new Dictionary(size); new Dictionary(size); new Dictionary(size); - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void GetItem(int size) - { - Dictionary dict = CreateDictionary(size); - - // Setup - int retrieved; - for (int i = 1; i <= 9; i++) - dict.Add(i, 0); - - // Actual perf testing - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - for (int i = 0; i <= 10000; i++) - { - retrieved = dict[1]; retrieved = dict[2]; retrieved = dict[3]; - retrieved = dict[4]; retrieved = dict[5]; retrieved = dict[6]; - retrieved = dict[7]; retrieved = dict[8]; retrieved = dict[9]; - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void SetItem(int size) - { - Dictionary dict = CreateDictionary(size); - // Setup - for (int i = 1; i <= 9; i++) - dict.Add(i, 0); - - // Actual perf testing - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - for (int i = 0; i <= 10000; i++) - { - dict[1] = 0; dict[2] = 0; dict[3] = 0; - dict[4] = 0; dict[5] = 0; dict[6] = 0; - dict[7] = 0; dict[8] = 0; dict[9] = 0; - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void GetKeys(int size) - { - Dictionary dict = CreateDictionary(size); - IEnumerable result; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i <= 20000; i++) - { - result = dict.Keys; result = dict.Keys; result = dict.Keys; - result = dict.Keys; result = dict.Keys; result = dict.Keys; - result = dict.Keys; result = dict.Keys; result = dict.Keys; - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void TryGetValue(int size) - { - Dictionary dict = CreateDictionary(size); - // Setup - utils needs a specific seed to prevent key collision with TestData - int retrieved; - Random rand = new Random(837322); - int key = rand.Next(0, 400000); - dict.Add(key, 12); - - // Actual perf testing - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i <= 1000; i++) - { - dict.TryGetValue(key, out retrieved); dict.TryGetValue(key, out retrieved); - dict.TryGetValue(key, out retrieved); dict.TryGetValue(key, out retrieved); - dict.TryGetValue(key, out retrieved); dict.TryGetValue(key, out retrieved); - dict.TryGetValue(key, out retrieved); dict.TryGetValue(key, out retrieved); - } - } - - [Benchmark] - [InlineData(1)] - [InlineData(10)] - [InlineData(1000)] - public static void Remove_ValueType(long size) - { - Dictionary collection = new Dictionary(); - long?[] items; - - items = new long?[size * 10]; - - for (long i = 0; i < size * 10; ++i) - { - items[i] = i; - collection.Add(items[i], items[i]); - } - - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (long i = 1; i < size; ++i) - collection.Remove(items[i]); - } - - [Benchmark] - public static void Indexer_get_ValueType() - { - int size = 1024; - int? item; - Dictionary collection = new Dictionary(); - for (int i = 0; i < size; ++i) - { - collection.Add(i, i); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < size; ++j) - { - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - item = (int)collection[j]; - } - } - } - } - - [Benchmark] - public static void Enumeration_ValueType() - { - int size = 1024; - int? key; - int? value; - Dictionary collection = new Dictionary(); - - for (int i = 0; i < size; ++i) - { - collection.Add(i, i); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - foreach (KeyValuePair tempItem in collection) - { - key = tempItem.Key; - value = tempItem.Value; - } - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsValue_Int_True(int sampleLength) - { - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - dictionary.Add(i, i); - } - - bool result = false; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsValue(j); //Every value searched for is present in the dictionary. - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsValue_Int_False(int sampleLength) - { - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - dictionary.Add(i, i); - } - - bool result = false; - - int missingValue = sampleLength; //The value sampleLength is not present in the dictionary. - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsValue(missingValue); - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsValue_String_True(int sampleLength) - { - string[] sampleValues = new string[sampleLength]; - - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - sampleValues[i] = i.ToString(); - - dictionary.Add(sampleValues[i], sampleValues[i]); - } - - bool result = false; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsValue(sampleValues[j]); //Every value searched for is present in the dictionary. - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsValue_String_False(int sampleLength) - { - string sampleValue; - - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - sampleValue = i.ToString(); - - dictionary.Add(sampleValue, sampleValue); - } - - bool result = false; - - string missingValue = sampleLength.ToString(); //The string representation of sampleLength is not present in the dictionary. - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsValue(missingValue); - } - - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsKey_Int_True(int sampleLength) - { - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - dictionary.Add(i, i); - } - - bool result = false; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsKey(j); - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsKey_Int_False(int sampleLength) - { - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - dictionary.Add(i, i); - } - - bool result = false; - - int missingKey = sampleLength; //The key sampleLength is not present in the dictionary. - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsKey(missingKey); - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsKey_String_True(int sampleLength) - { - string[] sampleKeys = new string[sampleLength]; - - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - sampleKeys[i] = i.ToString(); - - dictionary.Add(sampleKeys[i], sampleKeys[i]); - } - - bool result = false; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsKey(sampleKeys[j]); //Every key searched for is present in the dictionary. - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsKey_String_False(int sampleLength) - { - string sampleKey; - - Dictionary dictionary = new Dictionary(); - - for (int i = 0; i < sampleLength; i++) - { - sampleKey = i.ToString(); - - dictionary.Add(sampleKey, sampleKey); - } - - bool result = false; - - string missingKey = sampleLength.ToString(); //The string representation of sampleLength is not present in the dictionary. - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsKey(missingKey); - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public static void Dictionary_ContainsKey_String_False_IgnoreCase(int sampleLength) - { - string sampleKey; - - Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); - - for (int i = 0; i < sampleLength; i++) - { - sampleKey = i.ToString(); - - dictionary.Add(sampleKey, sampleKey); - } - - bool result = false; - - string missingKey = sampleLength.ToString(); //The string representation of sampleLength is not present in the dictionary. - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int j = 0; j < sampleLength; j++) - result = dictionary.ContainsKey(missingKey); - } - } -} diff --git a/src/libraries/System.Collections/tests/Performance/Perf.HashSet.cs b/src/libraries/System.Collections/tests/Performance/Perf.HashSet.cs deleted file mode 100644 index e15d09ea7428f..0000000000000 --- a/src/libraries/System.Collections/tests/Performance/Perf.HashSet.cs +++ /dev/null @@ -1,554 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Text; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Tests -{ - /// - /// Performs quick perf test of HashSet operations. Tests with T = int - /// - /// This is intended for the regular perf runs to catch perf regressions. - /// Use HashSetDetailedTests for detailed perf analysis. - /// - public class Perf_HashSet - { - private const int InitialSetSize = 8000000; - private const int InitialSetSize_small = 320000; - private const int MaxStartSize = 32000; - - [Benchmark] - [InlineData(InitialSetSize, 1)] - [InlineData(InitialSetSize, 100)] - [InlineData(InitialSetSize, 10000)] - public static void Add(int initialSetSize, int countToAdd) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - // n is varying start size of set - int[] startingElements = intGenerator.MakeNewTs(initialSetSize); - int[] stuffToAdd = intGenerator.MakeNewTs(countToAdd); - - foreach (var iteration in Benchmark.Iterations) - { - HashSet theSet = new HashSet(startingElements); - - using (iteration.StartMeasurement()) - { - foreach (int thing in stuffToAdd) - { - theSet.Add(thing); - } - } - } - } - - [Benchmark] - [InlineData(InitialSetSize, 1)] - [InlineData(InitialSetSize, 100)] - [InlineData(InitialSetSize, 10000)] - public static void Contains_True(int initialSetSize, int countToCheck) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(initialSetSize); - int[] subsetToCheck = intGenerator.GenerateSelectionSubset(startingElements, countToCheck); - bool present; - - foreach (var iteration in Benchmark.Iterations) - { - HashSet theSet = new HashSet(startingElements); - - using (iteration.StartMeasurement()) - { - foreach (int thing in subsetToCheck) - { - present = theSet.Contains(thing); - } - } - } - } - - [Benchmark] - [InlineData(InitialSetSize, 1)] - [InlineData(InitialSetSize, 100)] - [InlineData(InitialSetSize, 10000)] - public static void Contains_False(int initialSetSize, int countToCheck) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(initialSetSize); - int missingValue = InstanceCreators.IntGenerator_MaxValue + 1; - bool present; - - foreach (var iteration in Benchmark.Iterations) - { - HashSet theSet = new HashSet(startingElements); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < countToCheck; i++) - { - present = theSet.Contains(missingValue); - } - } - } - } - - [Benchmark] - [InlineData(InitialSetSize, 1)] - [InlineData(InitialSetSize, 100)] - [InlineData(InitialSetSize, 10000)] - public static void Remove(int initialSetSize, int countToRemove) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(initialSetSize); - int[] stuffToRemove = intGenerator.GenerateSelectionSubset(startingElements, countToRemove); - - foreach (var iteration in Benchmark.Iterations) - { - HashSet theSet = new HashSet(startingElements); - - using (iteration.StartMeasurement()) - { - foreach (int thing in stuffToRemove) - { - theSet.Remove(thing); - } - } - } - } - - [Benchmark] - [InlineData(InitialSetSize_small)] - public static void Clear(int initialSetSize) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingSet = intGenerator.MakeNewTs(initialSetSize); - HashSet theSet = new HashSet(); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingSet); - - using (iteration.StartMeasurement()) - theSet.Clear(); - } - } - - [Benchmark] - [InlineData(MaxStartSize, InitialSetSize_small)] - public static void Union(int startSize, int countToUnion) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToUnion = intGenerator.GenerateMixedSelection(startingElements, countToUnion); - HashSet theSet = new HashSet(); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingElements); - - using (iteration.StartMeasurement()) - theSet.UnionWith(stuffToUnion); - - theSet.Clear(); - } - } - - [Benchmark] - [InlineData(MaxStartSize, InitialSetSize_small)] - public static void Union_NoOp(int startSize, int countToUnion) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToUnion = intGenerator.GenerateMixedSelection(startingElements, countToUnion); - HashSet theSet = new HashSet(startingElements); - theSet.UnionWith(stuffToUnion); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - theSet.UnionWith(stuffToUnion); - } - } - - [Benchmark] - [InlineData(InitialSetSize_small, MaxStartSize)] - public static void IntersectHashSet(int startSize, int countToIntersect) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(startSize); - int[] stuffToIntersect = intGenerator.GenerateMixedSelection(startingElements, countToIntersect); - HashSet theSet = new HashSet(); - - HashSet hashSetToIntersect = new HashSet(stuffToIntersect); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingElements); - - using (iteration.StartMeasurement()) - theSet.IntersectWith(hashSetToIntersect); - - theSet.Clear(); - } - } - - [Benchmark] - [InlineData(MaxStartSize, InitialSetSize_small)] - private static void TestIntersectEnum(int startSize, int countToIntersect) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(startSize); - int[] stuffToIntersect = intGenerator.GenerateMixedSelection(startingElements, countToIntersect); - HashSet theSet = new HashSet(); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingElements); - - using (iteration.StartMeasurement()) - theSet.IntersectWith(stuffToIntersect); - - theSet.Clear(); - } - } - - [Benchmark] - [InlineData(MaxStartSize, InitialSetSize_small)] - public static void Except(int startSize, int countToExcept) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(startSize); - int[] stuffToExcept = intGenerator.GenerateMixedSelection(startingElements, countToExcept); - HashSet theSet = new HashSet(); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingElements); - - using (iteration.StartMeasurement()) - theSet.ExceptWith(stuffToExcept); - - theSet.Clear(); - } - } - - [Benchmark] - [InlineData(MaxStartSize, InitialSetSize_small)] - public static void SymmetricExcept(int startSize, int countToExcept) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(startSize); - int[] stuffToExcept = intGenerator.GenerateMixedSelection(startingElements, countToExcept); - HashSet theSet = new HashSet(); - HashSet otherSet = new HashSet(stuffToExcept); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingElements); - - using (iteration.StartMeasurement()) - theSet.SymmetricExceptWith(otherSet); - - theSet.Clear(); - } - } - - [Benchmark] - [InlineData(MaxStartSize, InitialSetSize_small)] - public static void SymmetricExceptEnum(int startSize, int countToExcept) - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(startSize); - int[] stuffToExcept = intGenerator.GenerateMixedSelection(startingElements, countToExcept); - HashSet theSet = new HashSet(); - - foreach (var iteration in Benchmark.Iterations) - { - theSet.UnionWith(startingElements); - - using (iteration.StartMeasurement()) - theSet.SymmetricExceptWith(stuffToExcept); - - theSet.Clear(); - } - } - - [Benchmark] - public static void TestIsSubsetHashSet() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - // this makes perf as bad as possible; has fallout case for count check - int[] additionalStuffToAdd = intGenerator.MakeNewTs((Math.Max(0, InitialSetSize_small - theSet.Count))); - HashSet setToCheckSubset = new HashSet(startingElements); - setToCheckSubset.UnionWith(additionalStuffToAdd); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsSubsetOf(setToCheckSubset); - } - - [Benchmark] - public static void TestIsSubsetEnum() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToCheckSubset = intGenerator.GenerateMixedSelection(startingElements, InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsSubsetOf(stuffToCheckSubset); - } - - [Benchmark] - public static void TestIsProperSubsetHashSet() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - // this makes perf as bad as possible; avoids fallout case based on count - int[] additionalStuffToAdd = intGenerator.MakeNewTs(Math.Max(0, InitialSetSize_small - theSet.Count)); - HashSet setToCheckSubset = new HashSet(startingElements); - setToCheckSubset.UnionWith(additionalStuffToAdd); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsProperSubsetOf(setToCheckSubset); - } - - [Benchmark] - public static void TestIsProperSubsetEnum() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToCheckSubset = intGenerator.GenerateMixedSelection(startingElements, InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsProperSubsetOf(stuffToCheckSubset); - } - - [Benchmark] - public static void TestIsSuperset() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToCheckSuperset = intGenerator.GenerateSelectionSubset(startingElements, InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsSupersetOf(stuffToCheckSuperset); - } - - [Benchmark] - public static void TestIsProperSupersetHashSet() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToCheckProperSuperset = intGenerator.GenerateSelectionSubset(startingElements, InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsProperSupersetOf(stuffToCheckProperSuperset); - } - - [Benchmark] - public static void TestIsProperSupersetEnum() - { - RandomTGenerator intGenerator = new RandomTGenerator(InstanceCreators.IntGenerator); - int[] startingElements = intGenerator.MakeNewTs(MaxStartSize); - int[] stuffToCheckProperSuperset = intGenerator.GenerateSelectionSubset(startingElements, InitialSetSize_small); - HashSet theSet = new HashSet(); - theSet.UnionWith(startingElements); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - theSet.IsProperSupersetOf(stuffToCheckProperSuperset); - } - } - - // Wrapper class for delegates capable of creating new instances of different types - public class InstanceCreators - { - public static int IntGenerator_MinValue - { - get { return -50000; } - } - - public static int IntGenerator_MaxValue - { - get { return 50000; } - } - - public static int IntGenerator(Random generator, int i) - { - return generator.Next(IntGenerator_MinValue, IntGenerator_MaxValue); - } - - public static DummyClass DummyGenerator(Random generator, int i) - { - return new DummyClass(string.Format("Dummy{0}", i)); - } - } - - // Generates T instances for use with HashSet perf tests - public class RandomTGenerator - { - private static Random s_sequenceGenerator; - private static Random s_elementGenerator; - - private Instantiate _instantiate; - - public delegate T Instantiate(Random elementGenerator, int i); - - static RandomTGenerator() - { - s_sequenceGenerator = new Random(); - s_elementGenerator = new Random(); - } - - public RandomTGenerator(Instantiate i) - { - _instantiate = i; - } - - public T[] MakeNewTs(int count) - { - T[] results = new T[count]; - for (int i = 0; i < count; i++) - { - results[i] = _instantiate(s_elementGenerator, i); - } - return results; - } - - public T[] GenerateSelectionSubset(T[] allObjects, int numToSelect) - { - T[] sequence = new T[numToSelect]; - int max = allObjects.Length - 1; - for (int i = 0; i < numToSelect; i++) - { - int nextInt = s_sequenceGenerator.Next(0, max); - sequence[i] = allObjects[nextInt]; - } - return sequence; - } - - public T[] GenerateMixedSelection(T[] allObjects, int numElements) - { - T[] sequence = new T[numElements]; - int max = allObjects.Length - 1; - for (int i = 0; i < numElements; i++) - { - if (i % 2 == 0) - { - int nextInt = s_sequenceGenerator.Next(0, max); - sequence[i] = allObjects[nextInt]; - } - else - { - sequence[i] = _instantiate(s_elementGenerator, i); - } - } - return sequence; - } - } - - #region DummyClass / helpers - // DummyClass is used for HashSet of object tests - public class DummyClass - { - private static Random s_nameRand; - private static Random s_percentRand; - - private string _id; - private string _name; - private double _percent; - - // initialize random generators - static DummyClass() - { - s_nameRand = new Random(); - s_percentRand = new Random(); - } - - public DummyClass(string id) - { - _id = id; - _name = RandomString(); - _percent = s_percentRand.NextDouble(); - } - - public string Id - { - get { return _id; } - set { _id = value; } - } - - public string Name - { - get { return _name; } - set { _name = value; } - } - - public double Percent - { - get { return _percent; } - set { _percent = value; } - } - - public override string ToString() - { - return _id; - } - - // Generates a random-ish string - private static string RandomString() - { - int size = s_nameRand.Next(0, 100); - - StringBuilder builder = new StringBuilder(); - char ch; - for (int i = 0; i < size; i++) - { - ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * s_nameRand.NextDouble() + 65))); - builder.Append(ch); - } - return builder.ToString(); - } - } - - // Dummy equality comparer for some DummyClass test cases where we want - // DummyClass value equality instead of reference - public class DummyClassEqualityComparer : IEqualityComparer - { - // Don't worry about boundary cases like null, etc; this is just for DummyClass test cases below - public bool Equals(DummyClass x, DummyClass y) - { - return x.Id.Equals(y.Id) && x.Name.Equals(y.Name) && x.Percent.Equals(y.Percent); - } - - public int GetHashCode(DummyClass obj) - { - return obj.Id.GetHashCode() | obj.Name.GetHashCode() | obj.Percent.GetHashCode(); - } - } - #endregion -} diff --git a/src/libraries/System.Collections/tests/Performance/Perf.List.cs b/src/libraries/System.Collections/tests/Performance/Perf.List.cs deleted file mode 100644 index efb6a605cf087..0000000000000 --- a/src/libraries/System.Collections/tests/Performance/Perf.List.cs +++ /dev/null @@ -1,1058 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Tests -{ - public class Perf_List - { - /// - /// Creates a list containing a number of elements equal to the specified size - /// - public static List CreateList(int size) - { - Random rand = new Random(24565653); - List list = new List(); - for (int i = 0; i < size; i++) - list.Add(rand.Next()); - return list; - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void Add(int size) - { - List list = CreateList(size); - foreach (var iteration in Benchmark.Iterations) - { - List copyList = new List(list); - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - copyList.Add(123555); copyList.Add(123555); copyList.Add(123555); copyList.Add(123555); - copyList.Add(123555); copyList.Add(123555); copyList.Add(123555); copyList.Add(123555); - } - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void AddRange(int size) - { - List list = CreateList(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 5000; i++) - { - List emptyList = new List(); - emptyList.AddRange(list); - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - public void Clear(int size) - { - List list = CreateList(size); - foreach (var iteration in Benchmark.Iterations) - { - // Setup lists to clear - List[] listlist = new List[5000]; - for (int i = 0; i < 5000; i++) - listlist[i] = new List(list); - - // Clear the lists - using (iteration.StartMeasurement()) - for (int i = 0; i < 5000; i++) - listlist[i].Clear(); - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void Contains(int size) - { - List list = CreateList(size); - object contained = list[list.Count / 2]; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 500; i++) - { - list.Contains(contained); list.Contains(contained); list.Contains(contained); list.Contains(contained); - list.Contains(contained); list.Contains(contained); list.Contains(contained); list.Contains(contained); - list.Contains(contained); list.Contains(contained); list.Contains(contained); list.Contains(contained); - } - } - } - - [Benchmark] - public void ctor() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 20000; i++) - { - new List(); new List(); new List(); new List(); new List(); - new List(); new List(); new List(); new List(); new List(); - new List(); new List(); new List(); new List(); new List(); - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void ctor_IEnumerable(int size) - { - List list = CreateList(size); - var array = list.ToArray(); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - new List(array); - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void GetCount(int size) - { - List list = CreateList(size); - int temp; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - temp = list.Count; temp = list.Count; temp = list.Count; temp = list.Count; temp = list.Count; - temp = list.Count; temp = list.Count; temp = list.Count; temp = list.Count; temp = list.Count; - temp = list.Count; temp = list.Count; temp = list.Count; temp = list.Count; temp = list.Count; - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void GetItem(int size) - { - List list = CreateList(size); - object temp; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; - temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; - temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; - temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; temp = list[50]; - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void Enumerator(int size) - { - List list = CreateList(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - foreach (var element in list) { } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void SetCapacity(int size) - { - List list = CreateList(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 100; i++) - { - // Capacity set back and forth between size+1 and size+2 - list.Capacity = size + (i % 2) + 1; - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void ToArray(int size) - { - List list = CreateList(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - list.ToArray(); - } - - [Benchmark] - public static void IndexOf_ValueType() - { - List collection = new List(); - int nonexistentItem, firstItem, middleItem, lastItem; - - for (int i = 0; i < 8192; ++i) - { - collection.Add(i); - } - - nonexistentItem = -1; - firstItem = 0; - middleItem = collection.Count / 2; - lastItem = collection.Count - 1; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - collection.IndexOf(nonexistentItem); - collection.IndexOf(firstItem); - collection.IndexOf(middleItem); - collection.IndexOf(lastItem); - } - } - } - - [Benchmark] - public static void IndexOf_ReferenceType() - { - List collection = new List(); - string nonexistentItem, firstItem, middleItem, lastItem; - - for (int i = 0; i < 8192; ++i) - { - collection.Add(i.ToString()); - } - - nonexistentItem = "foo"; - firstItem = 0.ToString(); - middleItem = (collection.Count / 2).ToString(); - lastItem = (collection.Count - 1).ToString(); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - collection.IndexOf(nonexistentItem); - collection.IndexOf(firstItem); - collection.IndexOf(middleItem); - collection.IndexOf(lastItem); - } - } - } - - private static int getSampleLength(bool largeSets) - { - if (largeSets) - return LARGE_SAMPLE_LENGTH; - else - return smallSampleLength; - } - - [Benchmark] - [InlineData(true)] - [InlineData(false)] - public static void GenericList_AddRange_Int_NoCapacityIncrease(bool largeSets) - { - int sampleLength = getSampleLength(largeSets); - - int[] sampleSet = new int[sampleLength]; - - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i; - } - - int addLoops = LARGE_SAMPLE_LENGTH / sampleLength; - - //Create an ArrayList big enough to hold 17 copies of the sample set - int startingCapacity = 17 * sampleLength * addLoops; - List list = new List(startingCapacity); - - //Add the data to the array list. - - for (int j = 0; j < addLoops; j++) - { - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - } - - foreach (var iteration in Benchmark.Iterations) - { - //Clear the ArrayList without changing its capacity, so that when more data is added to the list its - //capacity will not need to increase. - list.RemoveRange(0, startingCapacity); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < addLoops; j++) - { - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - } - } - } - } - - [Benchmark] - [InlineData(true)] - [InlineData(false)] - public static void GenericList_AddRange_Int_CapacityIncrease(bool largeSets) - { - int sampleLength = getSampleLength(largeSets); - - int[] sampleSet = new int[sampleLength]; - - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i; - } - - int addLoops = LARGE_SAMPLE_LENGTH / sampleLength; - - foreach (var iteration in Benchmark.Iterations) - { - List list = new List(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < addLoops; j++) - { - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - } - } - } - } - - [Benchmark] - [InlineData(true)] - [InlineData(false)] - public static void GenericList_AddRange_String_NoCapacityIncrease(bool largeSets) - { - int sampleLength = getSampleLength(largeSets); - - string[] sampleSet = new string[sampleLength]; - - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i.ToString(); - } - - int addLoops = LARGE_SAMPLE_LENGTH / sampleLength; - - //Create an ArrayList big enough to hold 17 copies of the sample set - int startingCapacity = 17 * sampleLength * addLoops; - List list = new List(startingCapacity); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < addLoops; j++) - { - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - } - } - - list.RemoveRange(0, startingCapacity); - } - } - - [Benchmark] - [InlineData(true)] - [InlineData(false)] - public static void GenericList_AddRange_String_CapacityIncrease(bool largeSets) - { - int sampleLength = getSampleLength(largeSets); - - string[] sampleSet = new string[sampleLength]; - - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i.ToString(); - } - - int addLoops = LARGE_SAMPLE_LENGTH / sampleLength; - - foreach (var iteration in Benchmark.Iterations) - { - List list = new List(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < addLoops; j++) - { - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - list.AddRange(sampleSet); - } - } - } - } - - [Benchmark] - public static void Add_ValueType() - { - foreach (var iteration in Benchmark.Iterations) - { - List collection = new List(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < 256; ++j) - { - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - collection.Add(j); - } - } - } - } - - [Benchmark] - public static void Add_ReferenceType() - { - string itemToAdd = "foo"; - - foreach (var iteration in Benchmark.Iterations) - { - List collection = new List(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < 256; ++j) - { - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - collection.Add(itemToAdd); - } - } - } - } - - [Benchmark] - public static void GenericList_BinarySearch_Int() - { - int sampleLength = 10000; - - int[] sampleSet = new int[sampleLength]; - - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i; - } - - List list = new List(sampleSet); - IComparer comparer = Comparer.Default; - - int result = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < sampleLength; j++) - result = list.BinarySearch(sampleSet[j], comparer); - } - } - } - - [Benchmark] - public static void GenericList_BinarySearch_String() - { - int sampleLength = 1000; - - string[] sampleSet = new string[sampleLength]; - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i.ToString(); - } - - List list = new List(sampleSet); - IComparer comparer = Comparer.Default; - - int result = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < sampleLength; j++) - result = list.BinarySearch(sampleSet[j], comparer); - } - } - } - - [Benchmark] - public static void Contains_ValueType() - { - List collection = new List(); - int nonexistentItem, firstItem, middleItem, lastItem; - - //[] Initialize - for (int i = 0; i < 8192; ++i) - { - collection.Add(i); - } - - nonexistentItem = -1; - firstItem = 0; - middleItem = collection.Count / 2; - lastItem = collection.Count - 1; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - collection.Contains(nonexistentItem); - collection.Contains(firstItem); - collection.Contains(middleItem); - collection.Contains(lastItem); - } - } - } - - [Benchmark] - public static void Contains_ReferenceType() - { - List collection = new List(); - string nonexistentItem, firstItem, middleItem, lastItem; - - //[] Initialize - for (int i = 0; i < 8192; ++i) - { - collection.Add(i.ToString()); - } - - nonexistentItem = "foo"; - firstItem = 0.ToString(); - middleItem = (collection.Count / 2).ToString(); - lastItem = (collection.Count - 1).ToString(); - - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - collection.Contains(nonexistentItem); - collection.Contains(firstItem); - collection.Contains(middleItem); - collection.Contains(lastItem); - } - } - } - - [Benchmark] - public static void ctor_ICollection_ValueType() - { - List originalCollection = new List(); - List newCollection; - - //[] Initialize - for (int i = 0; i < 1024; ++i) - { - originalCollection.Add(i); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - newCollection = new List(originalCollection); - } - } - } - - [Benchmark] - public static void ctor_ICollection_ReferenceType() - { - List originalCollection = new List(); - List newCollection; - - //[] Initialize - for (int i = 0; i < 1024; ++i) - { - originalCollection.Add(i.ToString()); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - newCollection = new List(originalCollection); - } - } - } - - [Benchmark] - public static void Indexer_ValueType() - { - List collection = new List(); - int item = 0; - - //[] Initialize - for (int i = 0; i < 8192; ++i) - { - collection.Add(i); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < 8192; ++j) - { - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - } - } - } - } - - [Benchmark] - public static void Indexer_ReferenceType() - { - List collection = new List(); - string item = null; - - //[] Initialize - for (int i = 0; i < 8192; ++i) - { - collection.Add(i.ToString()); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < 8192; ++j) - { - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - item = collection[j]; - } - } - } - } - - [Benchmark] - public static void Sort_ValueType() - { - Random random = new Random(32829); - int size = 3000; - int[] items; - List collection; - - //[] Initialize - items = new int[size]; - - for (int i = 0; i < size; ++i) - items[i] = random.Next(); - - foreach (var iteration in Benchmark.Iterations) - { - collection = new List(size); - - for (int j = 0; j < size; ++j) - collection.Add(items[j]); - - using (iteration.StartMeasurement()) - collection.Sort(); - } - } - - [Benchmark] - public static void Sort_ReferenceType() - { - Random random = new Random(32829); - int size = 3000; - string[] items; - List collection; - - //[] Initialize - items = new string[size]; - - for (int i = 0; i < size; ++i) - { - items[i] = random.Next().ToString(); - } - - foreach (var iteration in Benchmark.Iterations) - { - collection = new List(size); - - for (int j = 0; j < size; ++j) - { - collection.Add(items[j]); - } - - using (iteration.StartMeasurement()) - collection.Sort(); - } - } - - [Benchmark] - public static void GenericList_Reverse_Int() - { - int sampleLength = 100000; - - int[] sampleSet = new int[sampleLength]; - - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i; - } - - List list = new List(sampleSet); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - list.Reverse(); - } - - [Benchmark] - public static void GenericList_Reverse_String() - { - int sampleLength = 100000; - - string[] sampleSet = new string[sampleLength]; - for (int i = 0; i < sampleLength; i++) - { - sampleSet[i] = i.ToString(); - } - - List list = new List(sampleSet); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - list.Reverse(); - } - - [Benchmark] - public static void Remove_ValueType() - { - int size = 3000; - int[] items; - List collection; - int start, middle, end; - - //[] Initialize - items = new int[size]; - - for (int i = 0; i < size; ++i) - { - items[i] = i; - } - - foreach (var iteration in Benchmark.Iterations) - { - collection = new List(); - - for (int j = 0; j < size; ++j) - { - collection.Add(items[j]); - } - - start = 0; - middle = size / 3; - end = size - 1; - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < size / 3; j++) - { - collection.Remove(-1); - collection.Remove(items[start]); - collection.Remove(items[middle]); - collection.Remove(items[end]); - - ++start; - ++middle; - --end; - } - } - } - } - - [Benchmark] - public static void Remove_ReferenceType() - { - int size = 3000; - string[] items; - List collection; - int start, middle, end; - - //[] Initialize - items = new string[size]; - - for (int i = 0; i < size; ++i) - { - items[i] = i.ToString(); - } - - foreach (var iteration in Benchmark.Iterations) - { - collection = new List(); - - for (int j = 0; j < size; ++j) - { - collection.Add(items[j]); - } - - start = 0; - middle = size / 3; - end = size - 1; - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < size / 3; j++) - { - collection.Remove("-1"); - collection.Remove(items[start]); - collection.Remove(items[middle]); - collection.Remove(items[end]); - - ++start; - ++middle; - --end; - } - } - } - } - - [Benchmark] - public static void Insert_ValueType() - { - List collection; - - collection = new List(); - for (int j = 0; j < 1024; ++j) - { - collection.Insert(0, j);//Insert at the begining of the list - collection.Insert(j / 2, j);//Insert in the middle of the list - collection.Insert(collection.Count, j);//Insert at the end of the list - } - - foreach (var iteration in Benchmark.Iterations) - { - collection = new List(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < 1024; ++j) - { - collection.Insert(0, j);//Insert at the begining of the list - collection.Insert(j / 2, j);//Insert in the middle of the list - collection.Insert(collection.Count, j);//Insert at the end of the list - } - } - } - } - - [Benchmark] - public static void Insert_ReferenceType() - { - List collection; - string itemToAdd = "foo"; - - foreach (var iteration in Benchmark.Iterations) - { - collection = new List(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < 1024; ++j) - { - collection.Insert(0, itemToAdd);//Insert at the begining of the list - collection.Insert(j / 2, itemToAdd);//Insert in the middle of the list - collection.Insert(collection.Count, itemToAdd);//Insert at the end of the list - } - } - } - } - - [Benchmark] - public static void Enumeration_ValueType() - { - List collection = new List(); - int item; - - //[] Initialize - for (int i = 0; i < 8192; ++i) - { - collection.Add(i); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - foreach (int tempItem in collection) - { - item = tempItem; - } - } - } - } - - [Benchmark] - public static void Enumeration_ReferenceType() - { - List collection = new List(); - string item; - - //[] Initialize - for (int i = 0; i < 8192; ++i) - { - collection.Add(i.ToString()); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - foreach (string tempItem in collection) - { - item = tempItem; - } - } - } - } - - private const int LARGE_SAMPLE_LENGTH = 10000; - private const int SMALL_LOOPS = 1000; - - private const int smallSampleLength = LARGE_SAMPLE_LENGTH / SMALL_LOOPS; - } -} diff --git a/src/libraries/System.Collections/tests/Performance/System.Collections.PerformanceTests.csproj b/src/libraries/System.Collections/tests/Performance/System.Collections.PerformanceTests.csproj deleted file mode 100644 index 3f189d6d4bf2c..0000000000000 --- a/src/libraries/System.Collections/tests/Performance/System.Collections.PerformanceTests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - {F2B47C9D-477E-4EB2-B7F9-D7563FCED117} - true - netstandard-Debug;netstandard-Release - - - - Common\System\Collections\DictionaryExtensions.cs - - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 877552503aa5b827ec23f9109f73611a98939822 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:49:15 +0100 Subject: [PATCH 02/45] remove System.Collections.Concurrent.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/e6a0bb06d116204e4aca54885f02bb092b3b8960 --- .../System.Collections.Concurrent.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.ConcurrentBag.cs | 192 ------------------ .../Performance/Perf.ConcurrentDictionary.cs | 166 --------------- .../tests/Performance/Perf.ConcurrentQueue.cs | 164 --------------- .../tests/Performance/Perf.ConcurrentStack.cs | 192 ------------------ ...ections.Concurrent.PerformanceTests.csproj | 21 -- 7 files changed, 752 deletions(-) delete mode 100644 src/libraries/System.Collections.Concurrent/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentBag.cs delete mode 100644 src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentDictionary.cs delete mode 100644 src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentQueue.cs delete mode 100644 src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentStack.cs delete mode 100644 src/libraries/System.Collections.Concurrent/tests/Performance/System.Collections.Concurrent.PerformanceTests.csproj diff --git a/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln b/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln index eda71fa35d2be..5d763bd6b79bb 100644 --- a/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln +++ b/src/libraries/System.Collections.Concurrent/System.Collections.Concurrent.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.Concurre {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89} = {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.Concurrent.PerformanceTests", "tests\Performance\System.Collections.Concurrent.PerformanceTests.csproj", "{16568C86-E97E-42C6-B683-65A1B5AF2EC8}" - ProjectSection(ProjectDependencies) = postProject - {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89} = {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.Concurrent", "src\System.Collections.Concurrent.csproj", "{EA610394-CBA3-4E5C-B3DB-AAEA7F640E89}" ProjectSection(ProjectDependencies) = postProject {772CB0A7-3D45-4D3A-B975-671A1937C761} = {772CB0A7-3D45-4D3A-B975-671A1937C761} @@ -35,10 +30,6 @@ Global {9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {16568C86-E97E-42C6-B683-65A1B5AF2EC8}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {16568C86-E97E-42C6-B683-65A1B5AF2EC8}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {16568C86-E97E-42C6-B683-65A1B5AF2EC8}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {16568C86-E97E-42C6-B683-65A1B5AF2EC8}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {9574CEEC-5554-411B-B44C-6CA9EC1CEB08} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {16568C86-E97E-42C6-B683-65A1B5AF2EC8} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {EA610394-CBA3-4E5C-B3DB-AAEA7F640E89} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {772CB0A7-3D45-4D3A-B975-671A1937C761} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Collections.Concurrent/tests/Performance/Configurations.props b/src/libraries/System.Collections.Concurrent/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Collections.Concurrent/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentBag.cs b/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentBag.cs deleted file mode 100644 index a92d138ae2399..0000000000000 --- a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentBag.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Concurrent.Tests -{ - public class Perf_ConcurrentBag - { - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void Ctor() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long innerIters = Benchmark.InnerIterationCount / 10; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIters; i++) - { - new ConcurrentBag(); // 1 - new ConcurrentBag(); // 2 - new ConcurrentBag(); // 3 - new ConcurrentBag(); // 4 - new ConcurrentBag(); // 5 - new ConcurrentBag(); // 6 - new ConcurrentBag(); // 7 - new ConcurrentBag(); // 8 - new ConcurrentBag(); // 9 - new ConcurrentBag(); // 10 - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public void Add() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var q = new ConcurrentBag(); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - q.Add(i); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void TryTake(bool exists) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentBag(); - - if (exists) - { - for (int i = 0; i < size; i++) - { - b.Add(i); - } - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - b.TryTake(out int result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void AddTake() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentBag(); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - b.Add(i); - b.TryTake(out int result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(0)] - [InlineData(3)] - public void Pooling_AddTakeFromSameThreads(int initialSize) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - const int NumThreads = 2; - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentBag(); - - using (var barrier = new Barrier(NumThreads + 1)) - { - Task[] tasks = Enumerable.Range(0, NumThreads).Select(_ => Task.Factory.StartNew(() => - { - for (int i = 0; i < initialSize; i++) - { - b.Add(i); - } - - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - for (int i = 0; i < size; i++) - { - b.Add(i); - b.TryTake(out int result); - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)).ToArray(); - - barrier.SignalAndWait(); - using (iteration.StartMeasurement()) - { - barrier.SignalAndWait(); - Task.WaitAll(tasks); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void ProducerConsumer_AddTakeFromDifferentThreads() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - const int NumThreads = 2; - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentBag(); - - using (var barrier = new Barrier(NumThreads + 1)) - { - Task p = Task.Factory.StartNew(() => - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - for (int i = 0; i < size; i++) - { - b.Add(i); - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - - Task c = Task.Factory.StartNew(() => - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - int count = 0; - while (count < size) - { - if (b.TryTake(out int result)) - { - count++; - } - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - - barrier.SignalAndWait(); - using (iteration.StartMeasurement()) - { - barrier.SignalAndWait(); - Task.WaitAll(p, c); - } - } - } - } - } -} diff --git a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentDictionary.cs b/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentDictionary.cs deleted file mode 100644 index 1d575da89fc28..0000000000000 --- a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentDictionary.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Concurrent.Tests -{ - public class Perf_ConcurrentDictionary - { - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void Ctor() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long innerIters = Benchmark.InnerIterationCount / 10; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIters; i++) - { - new ConcurrentDictionary(); // 1 - new ConcurrentDictionary(); // 2 - new ConcurrentDictionary(); // 3 - new ConcurrentDictionary(); // 4 - new ConcurrentDictionary(); // 5 - new ConcurrentDictionary(); // 6 - new ConcurrentDictionary(); // 7 - new ConcurrentDictionary(); // 8 - new ConcurrentDictionary(); // 9 - new ConcurrentDictionary(); // 10 - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void TryAdd(bool exists) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - - var d = new ConcurrentDictionary(); - if (exists) - { - for (int i = 0; i < size; i++) - { - d.TryAdd(i, i); - } - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - d.TryAdd(i, i); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void TryGetValue(bool exists) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - - var d = new ConcurrentDictionary(); - for (int i = 0; i < size; i++) - { - d.TryAdd(exists ? i : i + size, i); - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - d.TryGetValue(i, out long result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void GetOrAdd(bool exists) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - - var d = new ConcurrentDictionary(); - for (int i = 0; i < size; i++) - { - d.TryAdd(exists ? i : i + size, i); - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - d.GetOrAdd(i, i); - } - } - } - } - - private static bool s_isEmptyResultNotUsed; - - [Benchmark(InnerIterationCount = 1_000_000)] - [InlineData(false)] - [InlineData(true)] - public void IsEmpty(bool isEmpty) - { - var d = new ConcurrentDictionary(); - if (!isEmpty) - { - d.TryAdd(42, 84); - } - - s_isEmptyResultNotUsed = true; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - s_isEmptyResultNotUsed &= d.IsEmpty; - } - } - } - } - - private static int s_sumNotUsed; - - [Benchmark(InnerIterationCount = 1_000_000)] - public void Count() - { - var d = new ConcurrentDictionary(); - for (int i = 0; i < 1000; i++) - { - d.TryAdd(i, i); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - s_sumNotUsed += d.Count; - } - } - } - } - } -} diff --git a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentQueue.cs b/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentQueue.cs deleted file mode 100644 index d74b194227955..0000000000000 --- a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentQueue.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Concurrent.Tests -{ - public class Perf_ConcurrentQueue - { - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void Ctor() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long innerIters = Benchmark.InnerIterationCount / 10; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIters; i++) - { - new ConcurrentQueue(); // 1 - new ConcurrentQueue(); // 2 - new ConcurrentQueue(); // 3 - new ConcurrentQueue(); // 4 - new ConcurrentQueue(); // 5 - new ConcurrentQueue(); // 6 - new ConcurrentQueue(); // 7 - new ConcurrentQueue(); // 8 - new ConcurrentQueue(); // 9 - new ConcurrentQueue(); // 10 - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public void Enqueue() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var q = new ConcurrentQueue(); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - q.Enqueue(i); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void TryDequeue(bool exists) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentQueue(); - - if (exists) - { - for (int i = 0; i < size; i++) - { - b.Enqueue(i); - } - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - b.TryDequeue(out int result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void EnqueueTryDequeue() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentQueue(); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - b.Enqueue(i); - b.TryDequeue(out int result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void ProducerConsumer_EnqueueTryDequeueFromDifferentThreads(bool presize) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - const int NumThreads = 2; - long size = Benchmark.InnerIterationCount; - var q = new ConcurrentQueue(); - - if (presize) - { - for (int i = 0; i < size * 2; i++) - { - q.Enqueue(i); - } - while (q.TryDequeue(out _)) - { - } - } - - using (var barrier = new Barrier(NumThreads + 1)) - { - Task p = Task.Factory.StartNew(() => - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - for (int i = 0; i < size; i++) - { - q.Enqueue(i); - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - - Task c = Task.Factory.StartNew(() => - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - int count = 0; - while (count < size) - { - if (q.TryDequeue(out int result)) - { - count++; - } - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - - barrier.SignalAndWait(); - using (iteration.StartMeasurement()) - { - barrier.SignalAndWait(); - Task.WaitAll(p, c); - } - } - } - } - } -} diff --git a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentStack.cs b/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentStack.cs deleted file mode 100644 index 243dcdcf88de5..0000000000000 --- a/src/libraries/System.Collections.Concurrent/tests/Performance/Perf.ConcurrentStack.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Concurrent.Tests -{ - public class Perf_ConcurrentStack - { - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void Ctor() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long innerIters = Benchmark.InnerIterationCount / 10; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIters; i++) - { - new ConcurrentStack(); // 1 - new ConcurrentStack(); // 2 - new ConcurrentStack(); // 3 - new ConcurrentStack(); // 4 - new ConcurrentStack(); // 5 - new ConcurrentStack(); // 6 - new ConcurrentStack(); // 7 - new ConcurrentStack(); // 8 - new ConcurrentStack(); // 9 - new ConcurrentStack(); // 10 - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public void Push() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var q = new ConcurrentStack(); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - q.Push(i); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(false)] - [InlineData(true)] - public void TryPop(bool exists) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentStack(); - - if (exists) - { - for (int i = 0; i < size; i++) - { - b.Push(i); - } - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - b.TryPop(out int result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void PushTryPop() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentStack(); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < size; i++) - { - b.Push(i); - b.TryPop(out int result); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - [InlineData(0)] - [InlineData(3)] - public void Pooling_PushTakeFromSameThreads(int initialSize) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - const int NumThreads = 2; - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentStack(); - - using (var barrier = new Barrier(NumThreads + 1)) - { - Task[] tasks = Enumerable.Range(0, NumThreads).Select(_ => Task.Factory.StartNew(() => - { - for (int i = 0; i < initialSize; i++) - { - b.Push(i); - } - - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - for (int i = 0; i < size; i++) - { - b.Push(i); - b.TryPop(out int result); - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)).ToArray(); - - barrier.SignalAndWait(); - using (iteration.StartMeasurement()) - { - barrier.SignalAndWait(); - Task.WaitAll(tasks); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void ProducerConsumer_PushTakeFromDifferentThreads() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - const int NumThreads = 2; - long size = Benchmark.InnerIterationCount; - var b = new ConcurrentStack(); - - using (var barrier = new Barrier(NumThreads + 1)) - { - Task p = Task.Factory.StartNew(() => - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - for (int i = 0; i < size; i++) - { - b.Push(i); - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - - Task c = Task.Factory.StartNew(() => - { - barrier.SignalAndWait(); - barrier.SignalAndWait(); - - int count = 0; - while (count < size) - { - if (b.TryPop(out int result)) - { - count++; - } - } - }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default); - - barrier.SignalAndWait(); - using (iteration.StartMeasurement()) - { - barrier.SignalAndWait(); - Task.WaitAll(p, c); - } - } - } - } - } -} diff --git a/src/libraries/System.Collections.Concurrent/tests/Performance/System.Collections.Concurrent.PerformanceTests.csproj b/src/libraries/System.Collections.Concurrent/tests/Performance/System.Collections.Concurrent.PerformanceTests.csproj deleted file mode 100644 index 56d0992933fe0..0000000000000 --- a/src/libraries/System.Collections.Concurrent/tests/Performance/System.Collections.Concurrent.PerformanceTests.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - {16568C86-E97E-42C6-B683-65A1B5AF2EC8} - netstandard-Debug;netstandard-Release - - - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 4d08bbd5e5f85ddad2fe757d42d562ba4fe19326 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:50:29 +0100 Subject: [PATCH 03/45] remove System.Collections.NonGeneric.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/f68eaf54e516d684fce1179c47b55e5059969f98 --- .../System.Collections.NonGeneric.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.ArrayList.cs | 486 ------------------ .../tests/Performance/Perf.HashTable.cs | 123 ----- ...ections.NonGeneric.PerformanceTests.csproj | 19 - 5 files changed, 645 deletions(-) delete mode 100644 src/libraries/System.Collections.NonGeneric/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.ArrayList.cs delete mode 100644 src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs delete mode 100644 src/libraries/System.Collections.NonGeneric/tests/Performance/System.Collections.NonGeneric.PerformanceTests.csproj diff --git a/src/libraries/System.Collections.NonGeneric/System.Collections.NonGeneric.sln b/src/libraries/System.Collections.NonGeneric/System.Collections.NonGeneric.sln index ca51616ad33a0..939df008257d5 100644 --- a/src/libraries/System.Collections.NonGeneric/System.Collections.NonGeneric.sln +++ b/src/libraries/System.Collections.NonGeneric/System.Collections.NonGeneric.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.NonGener {585E3764-534B-4A12-8BD5-8578CB826A45} = {585E3764-534B-4A12-8BD5-8578CB826A45} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.NonGeneric.PerformanceTests", "tests\Performance\System.Collections.NonGeneric.PerformanceTests.csproj", "{93AB3799-BC91-4B27-B526-28FFFF0DB1B1}" - ProjectSection(ProjectDependencies) = postProject - {585E3764-534B-4A12-8BD5-8578CB826A45} = {585E3764-534B-4A12-8BD5-8578CB826A45} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Collections.NonGeneric", "src\System.Collections.NonGeneric.csproj", "{585E3764-534B-4A12-8BD5-8578CB826A45}" ProjectSection(ProjectDependencies) = postProject {8500112F-96BD-47BF-8871-3242089FAE70} = {8500112F-96BD-47BF-8871-3242089FAE70} @@ -35,10 +30,6 @@ Global {EE95AE39-845A-42D3-86D0-8065DBE56612}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {EE95AE39-845A-42D3-86D0-8065DBE56612}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {EE95AE39-845A-42D3-86D0-8065DBE56612}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {93AB3799-BC91-4B27-B526-28FFFF0DB1B1}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {93AB3799-BC91-4B27-B526-28FFFF0DB1B1}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {93AB3799-BC91-4B27-B526-28FFFF0DB1B1}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {93AB3799-BC91-4B27-B526-28FFFF0DB1B1}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {585E3764-534B-4A12-8BD5-8578CB826A45}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {585E3764-534B-4A12-8BD5-8578CB826A45}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {585E3764-534B-4A12-8BD5-8578CB826A45}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {EE95AE39-845A-42D3-86D0-8065DBE56612} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {93AB3799-BC91-4B27-B526-28FFFF0DB1B1} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {585E3764-534B-4A12-8BD5-8578CB826A45} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {8500112F-96BD-47BF-8871-3242089FAE70} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Collections.NonGeneric/tests/Performance/Configurations.props b/src/libraries/System.Collections.NonGeneric/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Collections.NonGeneric/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.ArrayList.cs b/src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.ArrayList.cs deleted file mode 100644 index e2f9845686ebd..0000000000000 --- a/src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.ArrayList.cs +++ /dev/null @@ -1,486 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using System.Collections.Generic; -using Xunit; - -namespace System.Collections.Tests -{ - public class Perf_ArrayList - { - private static volatile int s_temp; - - private ArrayList CreateArrayListOfInts(int size = 100000) - { - var arrayListOfInts = new ArrayList(size); - for (int element = 0; element < size; element++) - { - arrayListOfInts.Add(element); - } - - return arrayListOfInts; - } - - private ArrayList CreateArrayList(int size = 100000) - { - var arrayListOfInts = new ArrayList(size); - var obj = new object(); - for (int i = 0; i < size; i++) - { - arrayListOfInts.Add(obj); - } - - return arrayListOfInts; - } - - [Benchmark(InnerIterationCount = 10000000)] - public void Add() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - var element = new object(); - foreach (var iteration in Benchmark.Iterations) - { - var elements = new ArrayList(); - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.Add(element); - } - } - } - } - - [Benchmark(InnerIterationCount = 6000)] - public void AddRange() - { - int size = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(1000); - foreach (var iteration in Benchmark.Iterations) - { - ArrayList[] elementsCollection = new ArrayList[size]; - for (int index = 0; index < size; index++) - { - elementsCollection[index] = new ArrayList(); - } - - using (iteration.StartMeasurement()) - { - for (int index = 0; index < size; index++) - { - elementsCollection[index].AddRange(elements); - } - } - } - } - - [Benchmark(InnerIterationCount = 10)] - public void BinarySearch() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayListOfInts(100000); - Comparer comparer = Comparer.Default; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int index = 0; index < innerIterationCount; index++) - { - for (int i = 0; i < elements.Count; i++) - { - elements.BinarySearch(i, comparer); - } - } - } - } - } - - [Benchmark(InnerIterationCount = 5000)] - public void Clear() - { - int size = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(10000); - foreach (var iteration in Benchmark.Iterations) - { - ArrayList[] elementsCollection = new ArrayList[size]; - for (int index = 0; index < size; index++) - { - elementsCollection[index] = new ArrayList(elements); - } - - using (iteration.StartMeasurement()) - { - for (int index = 0; index < size; index++) - { - elementsCollection[index].Clear(); - } - } - } - } - - [Benchmark(InnerIterationCount = 1000)] - public void Contains() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int size = 100000; - ArrayList elements = CreateArrayListOfInts(size); - object contained = elements[size / 2]; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.Contains(contained); - } - } - } - } - - [Benchmark(InnerIterationCount = 100000000)] - public void Ctor_Default() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - new ArrayList(); - } - } - } - } - - [Benchmark(InnerIterationCount = 10000)] - public void Ctor_ICollection() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(10000); - object[] array = elements.ToArray(); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - new ArrayList(array); - } - } - } - } - - [Benchmark(InnerIterationCount = 100000000)] - public void Count() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(10000); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - s_temp = elements.Count; - } - } - } - } - - [Benchmark(InnerIterationCount = 100000000)] - public void Indexer() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList((int)Benchmark.InnerIterationCount); - object temp; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int index = 0; index < innerIterationCount; index++) - { - temp = elements[index]; - } - } - } - } - - [Benchmark(InnerIterationCount = 10000)] - public void Enumerator() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(10000); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - foreach (var element in elements) - { } - } - } - } - } - - [Benchmark(InnerIterationCount = 10000)] - public void SetCapacity() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int size = 10000; - ArrayList elements = CreateArrayList(size); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - // Capacity set back and forth between "size + 1" and "size + 2" - elements.Capacity = size + (i % 2) + 1; - } - } - } - } - - [Benchmark(InnerIterationCount = 50000)] - public void ToArray() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - foreach (var iteration in Benchmark.Iterations) - { - ArrayList elements = CreateArrayList(10000); - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.ToArray(); - } - } - } - } - - [Benchmark(InnerIterationCount = 500)] - public void IndexOf() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayListOfInts(); - - int nonexistentElemetnt = -1; - int firstElemetnt = 0; - int middleElemetnt = elements.Count / 2; - int lastElemetnt = elements.Count - 1; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.IndexOf(nonexistentElemetnt); - elements.IndexOf(firstElemetnt); - elements.IndexOf(middleElemetnt); - elements.IndexOf(lastElemetnt); - } - } - } - } - - [Benchmark(InnerIterationCount = 10)] - [InlineData(0, 100000)] - [InlineData(99999, 100000)] - public void InsertRange(int index, int length) - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(length); - var arrayList = new ArrayList(elements); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - arrayList.InsertRange(index, elements); - } - } - } - } - - [Benchmark(InnerIterationCount = 50000)] - public void CopyTo() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int size = 10000; - ArrayList elements = CreateArrayList(size); - object[] destination = new object[size]; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.CopyTo(destination, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = 10000)] - public void LastIndexOf() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int size = 10000; - ArrayList elements = CreateArrayListOfInts(size); - int element = size / 2; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.LastIndexOf(element); - } - } - } - } - - [Benchmark(InnerIterationCount = 1000)] - public void Remove() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayListOfInts(); - int element = elements.Count / 2; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.Remove(element); - } - } - } - } - - [Benchmark(InnerIterationCount = 7000)] - public void RemoveRange() - { - int size = (int)Benchmark.InnerIterationCount; - ArrayList elements = CreateArrayList(size); - - foreach (var iteration in Benchmark.Iterations) - { - ArrayList[] elementsCollection = new ArrayList[size]; - for (int index = 0; index < size; index++) - { - elementsCollection[index] = new ArrayList(elements); - } - - using (iteration.StartMeasurement()) - { - for (int index = 0; index < size; index++) - { - elementsCollection[index].RemoveRange(1, size - 2); - } - } - } - } - - [Benchmark(InnerIterationCount = 1000)] - public void Reverse() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int startIndex = 0; - int count = 100000; - ArrayList elements = CreateArrayList(count); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.Reverse(startIndex, count); - } - } - } - } - - [Benchmark(InnerIterationCount = 10000000)] - public void SetRange() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int startIndex = 0; - int size = 100000; - ArrayList elements = CreateArrayList(size); - var newElemnts = new ArrayList(size); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.SetRange(startIndex, elements); - } - } - } - } - - [Benchmark(InnerIterationCount = 20000000)] - public void GetRange() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - int startIndex = 0; - int size = 100000; - ArrayList elements = CreateArrayList(size); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - elements.GetRange(startIndex, size); - } - } - } - } - - [Benchmark(InnerIterationCount = 10000000)] - public void Sort() - { - int size = (int)Benchmark.InnerIterationCount; - var random = new Random(32829); - ArrayList elements = new ArrayList(size); - for (int index = 0; index < elements.Count; index++) - { - elements.Add(random.Next()); - } - - foreach (var iteration in Benchmark.Iterations) - { - ArrayList[] elementsCollection = new ArrayList[size]; - for (int index = 0; index < size; index++) - { - elementsCollection[index] = new ArrayList(elements); - } - - using (iteration.StartMeasurement()) - { - for (int index = 0; index < size; index++) - { - elementsCollection[index].Sort(); - } - } - } - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs b/src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs deleted file mode 100644 index 0c91eb5260b30..0000000000000 --- a/src/libraries/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Collections.Tests -{ - public static class Perf_Hashtable - { - public static Hashtable CreateHashtable(int size) - { - var hash = new Hashtable(); - var rand = new Random(341553); - while (hash.Count < size) - { - int key = rand.Next(400000, int.MaxValue); - if (!hash.ContainsKey(key)) - hash.Add(key, rand.Next()); - } - return hash; - } - - [Benchmark] - public static void Ctor_Empty() - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 40000; i++) - { - new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); - new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); - new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); - new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); new Hashtable(); - } - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - [InlineData(1000000)] - public static void GetItem(int size) - { - Hashtable table = CreateHashtable(size); - - // Setup - utils needs a specific seed to prevent key collision with TestData - object result; - Random rand = new Random(3453); - int key = rand.Next(); - while (table.Contains(key)) - key = rand.Next(); - table.Add(key, rand.Next()); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 40000; i++) - { - result = table[key]; result = table[key]; result = table[key]; result = table[key]; - result = table[key]; result = table[key]; result = table[key]; result = table[key]; - result = table[key]; result = table[key]; result = table[key]; result = table[key]; - result = table[key]; result = table[key]; result = table[key]; result = table[key]; - } - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - [InlineData(1000000)] - public static void SetItem(int size) - { - Hashtable table = CreateHashtable(size); - var rand = new Random(3453); - int key = rand.Next(); - while (table.Contains(key)) - key = rand.Next(); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 40000; i++) - { - table[key] = "newValue"; table[key] = "newValue"; table[key] = "newValue"; - table[key] = "newValue"; table[key] = "newValue"; table[key] = "newValue"; - table[key] = "newValue"; table[key] = "newValue"; table[key] = "newValue"; - } - } - } - } - - [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - [InlineData(1000000)] - public static void Add(int size) - { - Hashtable table = CreateHashtable(size); - foreach (var iteration in Benchmark.Iterations) - { - Hashtable tableCopy = new Hashtable(table); - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 40000; i++) - { - tableCopy.Add(i * 10 + 1, "value"); tableCopy.Add(i * 10 + 2, "value"); tableCopy.Add(i * 10 + 3, "value"); - tableCopy.Add(i * 10 + 4, "value"); tableCopy.Add(i * 10 + 5, "value"); tableCopy.Add(i * 10 + 6, "value"); - tableCopy.Add(i * 10 + 7, "value"); tableCopy.Add(i * 10 + 8, "value"); tableCopy.Add(i * 10 + 9, "value"); - } - } - } - } - } -} diff --git a/src/libraries/System.Collections.NonGeneric/tests/Performance/System.Collections.NonGeneric.PerformanceTests.csproj b/src/libraries/System.Collections.NonGeneric/tests/Performance/System.Collections.NonGeneric.PerformanceTests.csproj deleted file mode 100644 index 134410bfcd342..0000000000000 --- a/src/libraries/System.Collections.NonGeneric/tests/Performance/System.Collections.NonGeneric.PerformanceTests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - {93AB3799-BC91-4B27-B526-28FFFF0DB1B1} - netstandard-Debug;netstandard-Release - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 2bffce995e2eafcf59e4fb03c4caaa1606537a4c Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:52:22 +0100 Subject: [PATCH 04/45] remove System.ComponentModel.TypeConverter.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/f7b67138cae13f1e299853cfdf50029e094b65b0 --- .../System.ComponentModel.TypeConverter.sln | 10 --- .../tests/Performance/Configurations.props | 8 --- .../Performance/Perf.TypeDescriptorTests.cs | 65 ------------------- ...odel.TypeConverter.PerformanceTests.csproj | 21 ------ 4 files changed, 104 deletions(-) delete mode 100644 src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Perf.TypeDescriptorTests.cs delete mode 100644 src/libraries/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.PerformanceTests.csproj diff --git a/src/libraries/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln b/src/libraries/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln index 09a2894362c44..fdb868b87691d 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln +++ b/src/libraries/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ComponentModel.TypeC {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F} = {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ComponentModel.TypeConverter.PerformanceTests", "tests\Performance\System.ComponentModel.TypeConverter.PerformanceTests.csproj", "{89C76728-ECAF-4905-A33F-BD6BFED5E91D}" - ProjectSection(ProjectDependencies) = postProject - {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F} = {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ComponentModel.TypeConverter", "src\System.ComponentModel.TypeConverter.csproj", "{AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}" ProjectSection(ProjectDependencies) = postProject {D35FD24C-1D1E-4860-B44D-73097CC0BD90} = {D35FD24C-1D1E-4860-B44D-73097CC0BD90} @@ -35,10 +30,6 @@ Global {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {3F0326A1-9E19-4A6C-95CE-63E65C9D2030} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {89C76728-ECAF-4905-A33F-BD6BFED5E91D} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {D35FD24C-1D1E-4860-B44D-73097CC0BD90} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Configurations.props b/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Configurations.props deleted file mode 100644 index f5d3d45ffbf44..0000000000000 --- a/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp; - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Perf.TypeDescriptorTests.cs b/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Perf.TypeDescriptorTests.cs deleted file mode 100644 index 5d6993c267c93..0000000000000 --- a/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/Perf.TypeDescriptorTests.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.ComponentModel.Tests -{ - public class Perf_TypeDescriptorTests - { - [Benchmark] - [InlineData(typeof(bool), typeof(BooleanConverter))] - [InlineData(typeof(byte), typeof(ByteConverter))] - [InlineData(typeof(sbyte), typeof(SByteConverter))] - [InlineData(typeof(char), typeof(CharConverter))] - [InlineData(typeof(double), typeof(DoubleConverter))] - [InlineData(typeof(string), typeof(StringConverter))] - [InlineData(typeof(short), typeof(Int16Converter))] - [InlineData(typeof(int), typeof(Int32Converter))] - [InlineData(typeof(long), typeof(Int64Converter))] - [InlineData(typeof(float), typeof(SingleConverter))] - [InlineData(typeof(ushort), typeof(UInt16Converter))] - [InlineData(typeof(uint), typeof(UInt32Converter))] - [InlineData(typeof(ulong), typeof(UInt64Converter))] - [InlineData(typeof(object), typeof(TypeConverter))] - [InlineData(typeof(void), typeof(TypeConverter))] - [InlineData(typeof(DateTime), typeof(DateTimeConverter))] - [InlineData(typeof(DateTimeOffset), typeof(DateTimeOffsetConverter))] - [InlineData(typeof(decimal), typeof(DecimalConverter))] - [InlineData(typeof(TimeSpan), typeof(TimeSpanConverter))] - [InlineData(typeof(Guid), typeof(GuidConverter))] - [InlineData(typeof(Array), typeof(ArrayConverter))] - [InlineData(typeof(ICollection), typeof(CollectionConverter))] - [InlineData(typeof(Enum), typeof(EnumConverter))] - [InlineData(typeof(SomeEnum), typeof(EnumConverter))] - [InlineData(typeof(SomeValueType?), typeof(NullableConverter))] - [InlineData(typeof(int?), typeof(NullableConverter))] - [InlineData(typeof(ClassWithNoConverter), typeof(TypeConverter))] - [InlineData(typeof(BaseClass), typeof(BaseClassConverter))] - [InlineData(typeof(DerivedClass), typeof(DerivedClassConverter))] - [InlineData(typeof(IBase), typeof(IBaseConverter))] - [InlineData(typeof(IDerived), typeof(IBaseConverter))] - [InlineData(typeof(ClassIBase), typeof(IBaseConverter))] - [InlineData(typeof(ClassIDerived), typeof(IBaseConverter))] - [InlineData(typeof(Uri), typeof(UriTypeConverter))] -#if netcoreapp - [InlineData(typeof(Version), typeof(VersionConverter))] -#endif - public static void GetConverter(Type typeToConvert, Type expectedConverter) - { - const int innerIterations = 100; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - { - TypeConverter converter = TypeDescriptor.GetConverter(typeToConvert); - Assert.NotNull(converter); - Assert.Equal(expectedConverter, converter.GetType()); - Assert.True(converter.CanConvertTo(typeof(string))); - } - } - } -} diff --git a/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.PerformanceTests.csproj b/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.PerformanceTests.csproj deleted file mode 100644 index a934c8b29de10..0000000000000 --- a/src/libraries/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.PerformanceTests.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - $(DefineConstants);PERFORMANCE_TESTS - {89C76728-ECAF-4905-A33F-BD6BFED5E91D} - 9.9.9.9 - netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From dbcdd7326acd99d0d0d1e270c94bd99c3ed3cf36 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:53:47 +0100 Subject: [PATCH 05/45] remove System.Console.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/03b2589f750119b8638c6f02b5e5ff04b1ace08b --- .../System.Console/System.Console.sln | 10 -- .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Console.cs | 152 ------------------ .../System.Console.PerformanceTests.csproj | 22 --- 4 files changed, 191 deletions(-) delete mode 100644 src/libraries/System.Console/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Console/tests/Performance/Perf.Console.cs delete mode 100644 src/libraries/System.Console/tests/Performance/System.Console.PerformanceTests.csproj diff --git a/src/libraries/System.Console/System.Console.sln b/src/libraries/System.Console/System.Console.sln index a84c03aa4931d..5f89e22e5bd9a 100644 --- a/src/libraries/System.Console/System.Console.sln +++ b/src/libraries/System.Console/System.Console.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Console.Manual.Tests {F9DF2357-81B4-4317-908E-512DA9395583} = {F9DF2357-81B4-4317-908E-512DA9395583} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Console.PerformanceTests", "tests\Performance\System.Console.PerformanceTests.csproj", "{14BE0BA2-28BC-467A-AA76-C6B86D21FDAE}" - ProjectSection(ProjectDependencies) = postProject - {F9DF2357-81B4-4317-908E-512DA9395583} = {F9DF2357-81B4-4317-908E-512DA9395583} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Console", "src\System.Console.csproj", "{F9DF2357-81B4-4317-908E-512DA9395583}" ProjectSection(ProjectDependencies) = postProject {9EB75B87-2BE5-48E5-8988-A0929CE6664E} = {9EB75B87-2BE5-48E5-8988-A0929CE6664E} @@ -44,10 +39,6 @@ Global {99E5069D-241F-48A6-8F29-404B4AED72BF}.Debug|Any CPU.Build.0 = Debug|Any CPU {99E5069D-241F-48A6-8F29-404B4AED72BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {99E5069D-241F-48A6-8F29-404B4AED72BF}.Release|Any CPU.Build.0 = Release|Any CPU - {14BE0BA2-28BC-467A-AA76-C6B86D21FDAE}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {14BE0BA2-28BC-467A-AA76-C6B86D21FDAE}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {14BE0BA2-28BC-467A-AA76-C6B86D21FDAE}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {14BE0BA2-28BC-467A-AA76-C6B86D21FDAE}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {F9DF2357-81B4-4317-908E-512DA9395583}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {F9DF2357-81B4-4317-908E-512DA9395583}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {F9DF2357-81B4-4317-908E-512DA9395583}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -63,7 +54,6 @@ Global GlobalSection(NestedProjects) = preSolution {3ED7BCF1-34B9-49B7-9C25-0BC3304C0858} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {99E5069D-241F-48A6-8F29-404B4AED72BF} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {14BE0BA2-28BC-467A-AA76-C6B86D21FDAE} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {F9DF2357-81B4-4317-908E-512DA9395583} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {9EB75B87-2BE5-48E5-8988-A0929CE6664E} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Console/tests/Performance/Configurations.props b/src/libraries/System.Console/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Console/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Console/tests/Performance/Perf.Console.cs b/src/libraries/System.Console/tests/Performance/Perf.Console.cs deleted file mode 100644 index 626f93386ae32..0000000000000 --- a/src/libraries/System.Console/tests/Performance/Perf.Console.cs +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.ConsoleTests -{ - /// - /// Perf tests for Console are chosen based on which functions have PAL code. They are: - /// - /// - OpenStandardInput, OpenStandardOutput, OpenStandardError - /// - ForegroundColor, BackgroundColor, ResetColor - /// - public class Perf_Console - { - [Benchmark] - public void OpenStandardInput() - { - // We preserve copies of each opened Stream so that the perf area doesn't - // cover the disposal of those streams. - const int innerIterations = 50; - Stream[] streams = new Stream[innerIterations * 4]; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - streams[0 + i * 4] = Console.OpenStandardInput(); streams[1 + i * 4] = Console.OpenStandardInput(); - streams[2 + i * 4] = Console.OpenStandardInput(); streams[3 + i * 4] = Console.OpenStandardInput(); - } - } - foreach (Stream s in streams) - s.Dispose(); - } - } - - [Benchmark] - public void OpenStandardOutput() - { - // We preserve copies of each opened Stream so that the perf area doesn't - // cover the disposal of those streams. - const int innerIterations = 50; - Stream[] streams = new Stream[innerIterations * 4]; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - streams[0 + i * 4] = Console.OpenStandardOutput(); streams[1 + i * 4] = Console.OpenStandardOutput(); - streams[2 + i * 4] = Console.OpenStandardOutput(); streams[3 + i * 4] = Console.OpenStandardOutput(); - } - } - foreach (Stream s in streams) - s.Dispose(); - } - } - - [Benchmark] - public void OpenStandardError() - { - // We preserve copies of each opened Stream so that the perf area doesn't - // cover the disposal of those streams. - const int innerIterations = 50; - Stream[] streams = new Stream[innerIterations * 4]; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - streams[0 + i * 4] = Console.OpenStandardError(); streams[1 + i * 4] = Console.OpenStandardError(); - streams[2 + i * 4] = Console.OpenStandardError(); streams[3 + i * 4] = Console.OpenStandardError(); - } - } - foreach (Stream s in streams) - s.Dispose(); - } - } - - [Benchmark] - public void ForegroundColor() - { - const int innerIterations = 1000; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - Console.ForegroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Blue; - Console.ForegroundColor = ConsoleColor.Cyan; Console.ForegroundColor = ConsoleColor.DarkBlue; - Console.ForegroundColor = ConsoleColor.DarkGray; Console.ForegroundColor = ConsoleColor.Red; - Console.ForegroundColor = ConsoleColor.DarkGreen; Console.ForegroundColor = ConsoleColor.White; - } - } - } - Console.ResetColor(); - } - - [Benchmark] - public void BackgroundColor() - { - const int innerIterations = 1000; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - Console.BackgroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Blue; - Console.BackgroundColor = ConsoleColor.Cyan; Console.BackgroundColor = ConsoleColor.DarkBlue; - Console.BackgroundColor = ConsoleColor.DarkGray; Console.BackgroundColor = ConsoleColor.Red; - Console.BackgroundColor = ConsoleColor.DarkGreen; Console.BackgroundColor = ConsoleColor.White; - } - } - } - Console.ResetColor(); -} - - [Benchmark] - public void ResetColor() - { - const int innerIterations = 1000; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - Console.ForegroundColor = ConsoleColor.DarkRed; Console.BackgroundColor = ConsoleColor.Cyan; - Console.ResetColor(); - Console.ForegroundColor = ConsoleColor.DarkRed; Console.BackgroundColor = ConsoleColor.Cyan; - Console.ResetColor(); - Console.ForegroundColor = ConsoleColor.DarkRed; Console.BackgroundColor = ConsoleColor.Cyan; - Console.ResetColor(); - Console.ForegroundColor = ConsoleColor.DarkRed; Console.BackgroundColor = ConsoleColor.Cyan; - Console.ResetColor(); - } - } - } - } - } -} diff --git a/src/libraries/System.Console/tests/Performance/System.Console.PerformanceTests.csproj b/src/libraries/System.Console/tests/Performance/System.Console.PerformanceTests.csproj deleted file mode 100644 index 105f3f10d6cd1..0000000000000 --- a/src/libraries/System.Console/tests/Performance/System.Console.PerformanceTests.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - true - {14BE0BA2-28BC-467A-AA76-C6B86D21FDAE} - netstandard-Debug;netstandard-Release - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - - - - \ No newline at end of file From c07c11993a0d43082cf859fe3e355aaad27018f6 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:55:48 +0100 Subject: [PATCH 06/45] remove System.Diagnostics.Process.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/064a9c74adbbecbb8ed4507ded3fcdbcc8ba7cb1 --- .../System.Diagnostics.Process.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Process.cs | 260 ------------------ ...iagnostics.Process.PerformanceTests.csproj | 32 --- 4 files changed, 309 deletions(-) delete mode 100644 src/libraries/System.Diagnostics.Process/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Diagnostics.Process/tests/Performance/Perf.Process.cs delete mode 100644 src/libraries/System.Diagnostics.Process/tests/Performance/System.Diagnostics.Process.PerformanceTests.csproj diff --git a/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln b/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln index 7267763334f6a..7941428f967fd 100644 --- a/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln +++ b/src/libraries/System.Diagnostics.Process/System.Diagnostics.Process.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Process. {F55047F8-E47B-46E3-B221-C23595AFE168} = {F55047F8-E47B-46E3-B221-C23595AFE168} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Process.PerformanceTests", "tests\Performance\System.Diagnostics.Process.PerformanceTests.csproj", "{4E05E43A-1DC9-47C7-8280-13CF4EF741EA}" - ProjectSection(ProjectDependencies) = postProject - {F55047F8-E47B-46E3-B221-C23595AFE168} = {F55047F8-E47B-46E3-B221-C23595AFE168} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Process", "src\System.Diagnostics.Process.csproj", "{F55047F8-E47B-46E3-B221-C23595AFE168}" ProjectSection(ProjectDependencies) = postProject {98B33275-39D8-4997-867D-04C69C69885E} = {98B33275-39D8-4997-867D-04C69C69885E} @@ -35,10 +30,6 @@ Global {E1114510-844C-4BB2-BBAD-8595BD16E24B}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {E1114510-844C-4BB2-BBAD-8595BD16E24B}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {E1114510-844C-4BB2-BBAD-8595BD16E24B}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {4E05E43A-1DC9-47C7-8280-13CF4EF741EA}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {4E05E43A-1DC9-47C7-8280-13CF4EF741EA}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {4E05E43A-1DC9-47C7-8280-13CF4EF741EA}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {4E05E43A-1DC9-47C7-8280-13CF4EF741EA}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {F55047F8-E47B-46E3-B221-C23595AFE168}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {F55047F8-E47B-46E3-B221-C23595AFE168}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {F55047F8-E47B-46E3-B221-C23595AFE168}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {E1114510-844C-4BB2-BBAD-8595BD16E24B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {4E05E43A-1DC9-47C7-8280-13CF4EF741EA} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {F55047F8-E47B-46E3-B221-C23595AFE168} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {98B33275-39D8-4997-867D-04C69C69885E} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Diagnostics.Process/tests/Performance/Configurations.props b/src/libraries/System.Diagnostics.Process/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Diagnostics.Process/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Process/tests/Performance/Perf.Process.cs b/src/libraries/System.Diagnostics.Process/tests/Performance/Perf.Process.cs deleted file mode 100644 index a6ab0ab69587a..0000000000000 --- a/src/libraries/System.Diagnostics.Process/tests/Performance/Perf.Process.cs +++ /dev/null @@ -1,260 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; -using Microsoft.Xunit.Performance; -using System.IO; -using System.Collections.Generic; - -namespace System.Diagnostics.Tests -{ - public class Perf_Process : ProcessTestBase - { - [Benchmark(Skip="Issue 16653")] - public void Kill() - { - const int inneriterations = 500; - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[inneriterations]; - for (int i = 0; i < inneriterations; i++) - { - processes[i] = CreateProcessLong(); - processes[i].Start(); - } - - // Begin Testing - Kill all of the processes - using (iteration.StartMeasurement()) - for (int i = 0; i < inneriterations; i++) - processes[i].Kill(); - - // Cleanup the processes - foreach (Process proc in processes) - { - proc.WaitForExit(); - proc.Dispose(); - } - } - } - - [Benchmark(Skip="Issue 16653")] - public void GetProcessesByName() - { - // To offset a different number of processes on a different machine, I create dummy processes - // until our baseline number is reached. - const int baseline = 300; - int numberOfProcesses = Process.GetProcesses().Length; - List processes = new List(); - while (numberOfProcesses++ <= baseline) - { - Process proc = CreateProcess(); - proc.Start(); - processes.Add(proc); - } - - // Begin testing - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - Process.GetProcessesByName("1"); Process.GetProcessesByName("1"); Process.GetProcessesByName("1"); - Process.GetProcessesByName("1"); Process.GetProcessesByName("1"); Process.GetProcessesByName("1"); - Process.GetProcessesByName("1"); Process.GetProcessesByName("1"); Process.GetProcessesByName("1"); - } - - // Cleanup - foreach (Process proc in processes) - { - if (!proc.HasExited) - proc.Kill(); - proc.WaitForExit(); - proc.Dispose(); - } - } - - [Benchmark(Skip="Issue 16653")] - public void GetId() - { - int id; - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[500]; - for (int i = 0; i < 500; i++) - { - processes[i] = CreateProcess(); - processes[i].Start(); - } - - // Begin Testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 500; i++) - id = processes[i].Id; - - foreach (Process proc in processes) - { - if (!proc.HasExited) - proc.Kill(); - proc.WaitForExit(); - proc.Dispose(); - } - } - } - - [Benchmark(Skip="Issue 16653")] - public void Start() - { - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[500]; - for (int i = 0; i < 500; i++) - { - processes[i] = CreateProcess(); - } - - // Begin Testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 500; i++) - processes[i].Start(); - - // Cleanup the processes - foreach (Process proc in processes) - { - if (!proc.HasExited) - proc.Kill(); - proc.WaitForExit(); - proc.Dispose(); - } - } - } - - [Benchmark(Skip="Issue 16653")] - public void GetHasExited() - { - bool result; - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[500]; - for (int i = 0; i < 500; i++) - { - processes[i] = CreateProcess(); - processes[i].Start(); - } - - // Begin Testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 500; i++) - result = processes[i].HasExited; - - // Cleanup the processes - foreach (Process proc in processes) - { - if (!proc.HasExited) - proc.Kill(); - proc.WaitForExit(); - proc.Dispose(); - } - } - } - - [Benchmark(Skip="Issue 16653")] - public void GetExitCode() - { - int result; - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[500]; - for (int i = 0; i < 500; i++) - { - processes[i] = CreateProcess(); - processes[i].Start(); - processes[i].WaitForExit(); - } - - // Begin Testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 500; i++) - result = processes[i].ExitCode; - - // Cleanup the processes - foreach (Process proc in processes) - { - proc.Dispose(); - } - } - } - - [Benchmark(Skip="Issue 16653")] - public void GetStartInfo() - { - ProcessStartInfo result; - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[500]; - for (int i = 0; i < 500; i++) - { - processes[i] = CreateProcess(); - processes[i].Start(); - } - - // Begin Testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 500; i++) - result = processes[i].StartInfo; - - // Cleanup the processes - foreach (Process proc in processes) - { - if (!proc.HasExited) - proc.Kill(); - proc.WaitForExit(); - proc.Dispose(); - } - } - } - - [Benchmark(Skip="Issue 16653")] - public void GetStandardOutput() - { - const int innerIterations = 200; - foreach (var iteration in Benchmark.Iterations) - { - // Create several processes to test on - Process[] processes = new Process[innerIterations]; - - Func method = () => - { - for (int j = 0; j < innerIterations; j++) - Console.WriteLine("Redirected String"); - return SuccessExitCode; - }; - - for (int i = 0; i < innerIterations; i++) - { - processes[i] = CreateProcess(method); - processes[i].StartInfo.RedirectStandardOutput = true; - processes[i].Start(); - } - - // Begin Testing - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - processes[i].StandardOutput.ReadToEnd(); - - // Cleanup the processes - foreach (Process proc in processes) - { - if (!proc.HasExited) - proc.Kill(); - proc.WaitForExit(); - proc.Dispose(); - } - } - } - } -} diff --git a/src/libraries/System.Diagnostics.Process/tests/Performance/System.Diagnostics.Process.PerformanceTests.csproj b/src/libraries/System.Diagnostics.Process/tests/Performance/System.Diagnostics.Process.PerformanceTests.csproj deleted file mode 100644 index 9b0e5c8f54608..0000000000000 --- a/src/libraries/System.Diagnostics.Process/tests/Performance/System.Diagnostics.Process.PerformanceTests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - true - {4E05E43A-1DC9-47C7-8280-13CF4EF741EA} - netstandard-Debug;netstandard-Release - - - - - - - - - Common\CoreLib\System\PasteArguments.cs - - - Common\System\IO\StringParser.cs - - - Common\System\PerfUtils.cs - - - Common\System\ShouldNotBeInvokedException.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - From 0f29da1c12a7e8dc57f6c55e196362d92aa6b824 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:57:56 +0100 Subject: [PATCH 07/45] remove System.Drawing.Common.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/06e7f93d77dc70fcfd592288a1a7b13d837324bd --- .../System.Drawing.Common.sln | 10 -- .../tests/Performance/Configurations.props | 7 - .../Performance/CustomAssemblyAttributes.cs | 7 - .../Performance/Perf_Graphics_DrawBeziers.cs | 64 -------- .../Performance/Perf_Graphics_Transforms.cs | 43 ----- .../tests/Performance/Perf_Image_Load.cs | 150 ------------------ ...tem.Drawing.Common.PerformanceTests.csproj | 27 ---- 7 files changed, 308 deletions(-) delete mode 100644 src/libraries/System.Drawing.Common/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Drawing.Common/tests/Performance/CustomAssemblyAttributes.cs delete mode 100644 src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_DrawBeziers.cs delete mode 100644 src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_Transforms.cs delete mode 100644 src/libraries/System.Drawing.Common/tests/Performance/Perf_Image_Load.cs delete mode 100644 src/libraries/System.Drawing.Common/tests/Performance/System.Drawing.Common.PerformanceTests.csproj diff --git a/src/libraries/System.Drawing.Common/System.Drawing.Common.sln b/src/libraries/System.Drawing.Common/System.Drawing.Common.sln index ca4f1b5d9ddaa..9688c0d8793b5 100644 --- a/src/libraries/System.Drawing.Common/System.Drawing.Common.sln +++ b/src/libraries/System.Drawing.Common/System.Drawing.Common.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common.Tests {191B3618-FECD-4ABD-9D6B-5AC90DC33621} = {191B3618-FECD-4ABD-9D6B-5AC90DC33621} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common.PerformanceTests", "tests\Performance\System.Drawing.Common.PerformanceTests.csproj", "{E66FFA55-0975-4F0D-8A18-24B2687FEDEA}" - ProjectSection(ProjectDependencies) = postProject - {191B3618-FECD-4ABD-9D6B-5AC90DC33621} = {191B3618-FECD-4ABD-9D6B-5AC90DC33621} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "src\System.Drawing.Common.csproj", "{191B3618-FECD-4ABD-9D6B-5AC90DC33621}" ProjectSection(ProjectDependencies) = postProject {D7AEA698-275D-441F-B7A7-8491D1F0EFF0} = {D7AEA698-275D-441F-B7A7-8491D1F0EFF0} @@ -35,10 +30,6 @@ Global {4B93E684-0630-45F4-8F63-6C7788C9892F}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {4B93E684-0630-45F4-8F63-6C7788C9892F}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {4B93E684-0630-45F4-8F63-6C7788C9892F}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {E66FFA55-0975-4F0D-8A18-24B2687FEDEA}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {E66FFA55-0975-4F0D-8A18-24B2687FEDEA}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {E66FFA55-0975-4F0D-8A18-24B2687FEDEA}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {E66FFA55-0975-4F0D-8A18-24B2687FEDEA}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {191B3618-FECD-4ABD-9D6B-5AC90DC33621}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {191B3618-FECD-4ABD-9D6B-5AC90DC33621}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {191B3618-FECD-4ABD-9D6B-5AC90DC33621}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {4B93E684-0630-45F4-8F63-6C7788C9892F} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {E66FFA55-0975-4F0D-8A18-24B2687FEDEA} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {191B3618-FECD-4ABD-9D6B-5AC90DC33621} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {D7AEA698-275D-441F-B7A7-8491D1F0EFF0} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Drawing.Common/tests/Performance/Configurations.props b/src/libraries/System.Drawing.Common/tests/Performance/Configurations.props deleted file mode 100644 index d6385a202011f..0000000000000 --- a/src/libraries/System.Drawing.Common/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - diff --git a/src/libraries/System.Drawing.Common/tests/Performance/CustomAssemblyAttributes.cs b/src/libraries/System.Drawing.Common/tests/Performance/CustomAssemblyAttributes.cs deleted file mode 100644 index 6bfb479689c71..0000000000000 --- a/src/libraries/System.Drawing.Common/tests/Performance/CustomAssemblyAttributes.cs +++ /dev/null @@ -1,7 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; - -[assembly: TestCaseOrderer("Microsoft.DotNet.XUnitExtensions.BenchmarkFilter", "System.Drawing.Common.PerformanceTests")] diff --git a/src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_DrawBeziers.cs b/src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_DrawBeziers.cs deleted file mode 100644 index b3ed6dd73c910..0000000000000 --- a/src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_DrawBeziers.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; -using Microsoft.Xunit.Performance; -using Microsoft.DotNet.XUnitExtensions; - -namespace System.Drawing.Tests -{ - public class Perf_Graphics_DrawBeziers : RemoteExecutorTestBase - { - [Benchmark(InnerIterationCount = 10000)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported))] - public void DrawBezier_Point() - { - Random r = new Random(1942); - - using (Bitmap image = new Bitmap(100, 100)) - using (Pen pen = new Pen(Color.White)) - using (Graphics graphics = Graphics.FromImage(image)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - graphics.DrawBezier(pen, new Point(r.Next(100), r.Next(100)), new Point(r.Next(100), r.Next(100)), new Point(r.Next(100), r.Next(100)), new Point(r.Next(100), r.Next(100))); - } - } - } - } - } - - [Benchmark(InnerIterationCount = 10000)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported))] - public void DrawBezier_Points() - { - Point[] points = - { - new Point(10, 10), new Point(20, 1), new Point(35, 5), new Point(50, 10), - new Point(60, 15), new Point(65, 25), new Point(50, 30) - }; - - using (Bitmap image = new Bitmap(100, 100)) - using (Pen pen = new Pen(Color.Blue)) - using (Graphics graphics = Graphics.FromImage(image)) - { - foreach (var iteration in Benchmark.Iterations) - { - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - graphics.DrawBeziers(pen, points); - } - } - } - } - } - } -} diff --git a/src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_Transforms.cs b/src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_Transforms.cs deleted file mode 100644 index c53628b966f89..0000000000000 --- a/src/libraries/System.Drawing.Common/tests/Performance/Perf_Graphics_Transforms.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; -using System.Drawing.Drawing2D; -using Microsoft.Xunit.Performance; -using Microsoft.DotNet.XUnitExtensions; - -namespace System.Drawing.Tests -{ - public class Perf_Graphics_Transforms : RemoteExecutorTestBase - { - [Benchmark(InnerIterationCount = 10000)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported), nameof(Helpers.IsNotUnix))] // Graphics.TransformPoints is not implemented in libgdiplus yet. See dotnet/corefx 20884 - public void TransformPoints() - { - Point[] points = - { - new Point(10, 10), new Point(20, 1), new Point(35, 5), new Point(50, 10), - new Point(60, 15), new Point(65, 25), new Point(50, 30) - }; - - using (Bitmap image = new Bitmap(100, 100)) - using (Graphics graphics = Graphics.FromImage(image)) - { - foreach (var iteration in Benchmark.Iterations) - { - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - graphics.TransformPoints(CoordinateSpace.World, CoordinateSpace.Page, points); - graphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.World, points); - graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, points); - } - } - } - } - } - } -} diff --git a/src/libraries/System.Drawing.Common/tests/Performance/Perf_Image_Load.cs b/src/libraries/System.Drawing.Common/tests/Performance/Perf_Image_Load.cs deleted file mode 100644 index 472a042e7501a..0000000000000 --- a/src/libraries/System.Drawing.Common/tests/Performance/Perf_Image_Load.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; -using System.Drawing.Imaging; -using System.IO; -using Microsoft.Xunit.Performance; -using Microsoft.DotNet.XUnitExtensions; - -namespace System.Drawing.Tests -{ - public class Perf_Image_Load : RemoteExecutorTestBase - { - [Benchmark(InnerIterationCount = 100)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported))] - public void Bitmap_FromStream() - { - var files = CreateTestImageFiles(); - - using (FileStream bmpStream = new FileStream(files.BitmapPath, FileMode.Open, FileAccess.Read)) - using (FileStream jpgStream = new FileStream(files.JpegPath, FileMode.Open, FileAccess.Read)) - using (FileStream pngStream = new FileStream(files.PngPath, FileMode.Open, FileAccess.Read)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - using (new Bitmap(bmpStream)) - using (new Bitmap(jpgStream)) - using (new Bitmap(pngStream)) - { - } - } - } - } - } - } - - [Benchmark(InnerIterationCount = 100)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported))] - public void Image_FromStream() - { - var files = CreateTestImageFiles(); - - using (FileStream bmpStream = new FileStream(files.BitmapPath, FileMode.Open, FileAccess.Read)) - using (FileStream jpgStream = new FileStream(files.JpegPath, FileMode.Open, FileAccess.Read)) - using (FileStream pngStream = new FileStream(files.PngPath, FileMode.Open, FileAccess.Read)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - using (Image.FromStream(bmpStream)) - using (Image.FromStream(jpgStream)) - using (Image.FromStream(pngStream)) - { - } - } - } - } - } - } - - [Benchmark(InnerIterationCount = 100)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported))] - public void Image_FromStream_NoValidation() - { - var files = CreateTestImageFiles(); - - using (FileStream bmpStream = new FileStream(files.BitmapPath, FileMode.Open, FileAccess.Read)) - using (FileStream jpgStream = new FileStream(files.JpegPath, FileMode.Open, FileAccess.Read)) - using (FileStream pngStream = new FileStream(files.PngPath, FileMode.Open, FileAccess.Read)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - using (Image.FromStream(bmpStream, false, false)) - using (Image.FromStream(jpgStream, false, false)) - using (Image.FromStream(pngStream, false, false)) - { - } - } - } - } - } - } - - [Benchmark(InnerIterationCount = 100)] - [ConditionalBenchmark(typeof(Helpers), nameof(Helpers.GetIsDrawingSupported))] - public void Image_FromStream_NoValidation_Gif() - { - // GIF has extra logic looking for animated GIFs - string gifPath = CreateTestImageFile(ImageFormat.Gif); - - using (FileStream gifStream = new FileStream(gifPath, FileMode.Open, FileAccess.Read)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - using (Image.FromStream(gifStream, false, false)) - { - } - } - } - } - } - } - - private (string BitmapPath, string JpegPath, string PngPath) CreateTestImageFiles() - { - return (CreateTestImageFile(ImageFormat.Bmp), CreateTestImageFile(ImageFormat.Bmp), CreateTestImageFile(ImageFormat.Bmp)); - } - - private string CreateTestImageFile(ImageFormat format) - { - string path = GetTestFilePath(); - path = $"{path}.{format.ToString().ToLowerInvariant()}"; - - Random r = new Random(1066); - - const int Size = 1000; - Point RandomPoint() => new Point(r.Next(Size), r.Next(Size)); - - using (Bitmap bitmap = new Bitmap(Size, Size)) - using (Pen pen = new Pen(Color.Blue)) - using (Graphics graphics = Graphics.FromImage(bitmap)) - { - for (int i = 0; i < 100; i++) - { - graphics.DrawBezier(pen, RandomPoint(), RandomPoint(), RandomPoint(), RandomPoint()); - } - - bitmap.Save(path, format); - } - - return path; - } - } -} diff --git a/src/libraries/System.Drawing.Common/tests/Performance/System.Drawing.Common.PerformanceTests.csproj b/src/libraries/System.Drawing.Common/tests/Performance/System.Drawing.Common.PerformanceTests.csproj deleted file mode 100644 index 84a710192b436..0000000000000 --- a/src/libraries/System.Drawing.Common/tests/Performance/System.Drawing.Common.PerformanceTests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - {E66FFA55-0975-4F0D-8A18-24B2687FEDEA} - netstandard-Debug;netstandard-Release - - - - - - - - Common\System\PerfUtils.cs - - - Common\Performance\BenchmarkFilter.cs - - - Common\System\Drawing\Helpers.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 7c48fb3f70ba23d609e9de8bf1dc08174e900ab4 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 06:58:55 +0100 Subject: [PATCH 08/45] remove System.Drawing.Primitives.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/c9f3a41467700c73fa44aafd6e296f8dc4c29a1e --- .../System.Drawing.Primitives.sln | 10 -- .../tests/Performance/Configurations.props | 7 -- .../tests/Performance/Perf_Color.cs | 118 ------------------ ...Drawing.Primitives.PerformanceTests.csproj | 15 --- 4 files changed, 150 deletions(-) delete mode 100644 src/libraries/System.Drawing.Primitives/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Drawing.Primitives/tests/Performance/Perf_Color.cs delete mode 100644 src/libraries/System.Drawing.Primitives/tests/Performance/System.Drawing.Primitives.PerformanceTests.csproj diff --git a/src/libraries/System.Drawing.Primitives/System.Drawing.Primitives.sln b/src/libraries/System.Drawing.Primitives/System.Drawing.Primitives.sln index a5160c8d3b91f..51970ae096808 100644 --- a/src/libraries/System.Drawing.Primitives/System.Drawing.Primitives.sln +++ b/src/libraries/System.Drawing.Primitives/System.Drawing.Primitives.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Primitives.T {8F472B93-574C-4AEC-9D28-6C2360A55BBF} = {8F472B93-574C-4AEC-9D28-6C2360A55BBF} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Primitives.PerformanceTests", "tests\Performance\System.Drawing.Primitives.PerformanceTests.csproj", "{1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3}" - ProjectSection(ProjectDependencies) = postProject - {8F472B93-574C-4AEC-9D28-6C2360A55BBF} = {8F472B93-574C-4AEC-9D28-6C2360A55BBF} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Primitives", "src\System.Drawing.Primitives.csproj", "{8F472B93-574C-4AEC-9D28-6C2360A55BBF}" ProjectSection(ProjectDependencies) = postProject {10F74537-6423-48F5-A7F3-4DE94E42AF8F} = {10F74537-6423-48F5-A7F3-4DE94E42AF8F} @@ -35,10 +30,6 @@ Global {CF54638C-A382-4A78-9AD6-2304CEEFEB01}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {CF54638C-A382-4A78-9AD6-2304CEEFEB01}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {CF54638C-A382-4A78-9AD6-2304CEEFEB01}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {8F472B93-574C-4AEC-9D28-6C2360A55BBF}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {8F472B93-574C-4AEC-9D28-6C2360A55BBF}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {8F472B93-574C-4AEC-9D28-6C2360A55BBF}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF54638C-A382-4A78-9AD6-2304CEEFEB01} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {8F472B93-574C-4AEC-9D28-6C2360A55BBF} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {10F74537-6423-48F5-A7F3-4DE94E42AF8F} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Drawing.Primitives/tests/Performance/Configurations.props b/src/libraries/System.Drawing.Primitives/tests/Performance/Configurations.props deleted file mode 100644 index a1eadd7648d83..0000000000000 --- a/src/libraries/System.Drawing.Primitives/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netcoreapp; - - - diff --git a/src/libraries/System.Drawing.Primitives/tests/Performance/Perf_Color.cs b/src/libraries/System.Drawing.Primitives/tests/Performance/Perf_Color.cs deleted file mode 100644 index 6dfd283050aac..0000000000000 --- a/src/libraries/System.Drawing.Primitives/tests/Performance/Perf_Color.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using Microsoft.Xunit.Performance; - -namespace System.Drawing.Tests -{ - public class Perf_Color : RemoteExecutorTestBase - { - public static readonly Color[] AllKnownColors; - - static Perf_Color() - { - AllKnownColors = typeof(Color) - .GetProperties(BindingFlags.Static | BindingFlags.Public) - .Where(p => p.PropertyType == typeof(Color)) - .Select(p => (Color)p.GetValue(null)) - .ToArray(); - } - - [Benchmark(InnerIterationCount = 10_000_000)] - public void FromArgb_Channels() - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - int val = i & 0xFF; - Color.FromArgb(byte.MaxValue, val, byte.MinValue, val); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000)] - public void FromArgb_AlphaColor() - { - foreach (var iteration in Benchmark.Iterations) - { - var baseColor = Color.DarkSalmon; - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Color.FromArgb(i & 0xFF, baseColor); - } - } - } - } - - [Benchmark(InnerIterationCount = 100_000)] - public void GetBrightness() - { - foreach (var iteration in Benchmark.Iterations) - { - var colors = AllKnownColors; - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < colors.Length; j++) - { - colors[j].GetBrightness(); - } - } - } - } - } - - [Benchmark(InnerIterationCount = 100_000)] - public void GetHue() - { - foreach (var iteration in Benchmark.Iterations) - { - var colors = AllKnownColors; - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < colors.Length; j++) - { - colors[j].GetHue(); - } - } - } - } - } - - [Benchmark(InnerIterationCount = 100_000)] - public void GetSaturation() - { - foreach (var iteration in Benchmark.Iterations) - { - var colors = AllKnownColors; - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < colors.Length; j++) - { - colors[j].GetSaturation(); - } - } - } - } - } - } -} diff --git a/src/libraries/System.Drawing.Primitives/tests/Performance/System.Drawing.Primitives.PerformanceTests.csproj b/src/libraries/System.Drawing.Primitives/tests/Performance/System.Drawing.Primitives.PerformanceTests.csproj deleted file mode 100644 index 2170057cb0026..0000000000000 --- a/src/libraries/System.Drawing.Primitives/tests/Performance/System.Drawing.Primitives.PerformanceTests.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - {1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3} - netcoreapp-Debug;netcoreapp-Release - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From f3158f52d690fc1235331e634063e75ee306bd20 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:01:10 +0100 Subject: [PATCH 09/45] remove System.Globalization.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/7a1369795e2d3bc1769a3f4ed574e1fa2e0b5800 --- .../System.Globalization.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.CompareInfo.cs | 177 ------------------ .../tests/Performance/Perf.CultureInfo.cs | 44 ----- .../Performance/Perf.DateTimeCultureInfo.cs | 61 ------ .../Performance/Perf.NumberCultureInfo.cs | 38 ---- ...stem.Globalization.PerformanceTests.csproj | 27 --- 7 files changed, 364 deletions(-) delete mode 100644 src/libraries/System.Globalization/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Globalization/tests/Performance/Perf.CompareInfo.cs delete mode 100644 src/libraries/System.Globalization/tests/Performance/Perf.CultureInfo.cs delete mode 100644 src/libraries/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs delete mode 100644 src/libraries/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs delete mode 100644 src/libraries/System.Globalization/tests/Performance/System.Globalization.PerformanceTests.csproj diff --git a/src/libraries/System.Globalization/System.Globalization.sln b/src/libraries/System.Globalization/System.Globalization.sln index 5170150af534d..fa0df39c5b5df 100644 --- a/src/libraries/System.Globalization/System.Globalization.sln +++ b/src/libraries/System.Globalization/System.Globalization.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Invariant.Tests", "tests\In {2395E8CA-73CB-40DF-BE40-A60BC189B737} = {2395E8CA-73CB-40DF-BE40-A60BC189B737} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Globalization.PerformanceTests", "tests\Performance\System.Globalization.PerformanceTests.csproj", "{0BA6851E-0E75-453D-9D2A-CEB94E4DE975}" - ProjectSection(ProjectDependencies) = postProject - {2395E8CA-73CB-40DF-BE40-A60BC189B737} = {2395E8CA-73CB-40DF-BE40-A60BC189B737} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Globalization", "src\System.Globalization.csproj", "{2395E8CA-73CB-40DF-BE40-A60BC189B737}" ProjectSection(ProjectDependencies) = postProject {E1E58C98-808F-4065-9C1D-E6411166AF6F} = {E1E58C98-808F-4065-9C1D-E6411166AF6F} @@ -44,10 +39,6 @@ Global {9A8926D9-1D4C-4069-8965-A626F6CA8C29}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {9A8926D9-1D4C-4069-8965-A626F6CA8C29}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {9A8926D9-1D4C-4069-8965-A626F6CA8C29}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {0BA6851E-0E75-453D-9D2A-CEB94E4DE975}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {0BA6851E-0E75-453D-9D2A-CEB94E4DE975}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {0BA6851E-0E75-453D-9D2A-CEB94E4DE975}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {0BA6851E-0E75-453D-9D2A-CEB94E4DE975}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {2395E8CA-73CB-40DF-BE40-A60BC189B737}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {2395E8CA-73CB-40DF-BE40-A60BC189B737}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {2395E8CA-73CB-40DF-BE40-A60BC189B737}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -63,7 +54,6 @@ Global GlobalSection(NestedProjects) = preSolution {484C92C6-6D2C-45BC-A5E2-4A12BA228E1E} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {9A8926D9-1D4C-4069-8965-A626F6CA8C29} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {0BA6851E-0E75-453D-9D2A-CEB94E4DE975} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {2395E8CA-73CB-40DF-BE40-A60BC189B737} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {E1E58C98-808F-4065-9C1D-E6411166AF6F} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Globalization/tests/Performance/Configurations.props b/src/libraries/System.Globalization/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Globalization/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Globalization/tests/Performance/Perf.CompareInfo.cs b/src/libraries/System.Globalization/tests/Performance/Perf.CompareInfo.cs deleted file mode 100644 index 6f56fcf932372..0000000000000 --- a/src/libraries/System.Globalization/tests/Performance/Perf.CompareInfo.cs +++ /dev/null @@ -1,177 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; -using Microsoft.Xunit.Performance; -using System.Collections.Generic; - -namespace System.Globalization.Tests -{ - public class Perf_CompareInfo - { - private static string GenerateInputString(char source, int count, char replaceChar, int replacePos) - { - char[] str = new char[count]; - for (int i = 0; i < count; i++) - { - str[i] = replaceChar; - } - str[replacePos] = replaceChar; - - return new string(str); - } - - public static IEnumerable s_compareTestData = new List - { - new object[] { "", "string1", "string2", CompareOptions.None }, - new object[] { "tr-TR", "StrIng", "string", CompareOptions.IgnoreCase }, - new object[] { "en-US", "StrIng", "string", CompareOptions.OrdinalIgnoreCase }, - new object[] { "", "\u3060", "\u305F", CompareOptions.None }, - new object[] { "ja-JP", "ABCDE", "c", CompareOptions.None }, - new object[] { "es-ES", "$", "&", CompareOptions.IgnoreSymbols }, - new object[] { "", GenerateInputString('A', 10, '5', 5), GenerateInputString('A', 10, '5', 6), CompareOptions.Ordinal }, - new object[] { "", GenerateInputString('A', 100, 'X', 70), GenerateInputString('A', 100, 'X', 70), CompareOptions.OrdinalIgnoreCase }, - new object[] { "ja-JP", GenerateInputString('A', 100, 'D', 70), GenerateInputString('A', 100, 'd', 70), CompareOptions.OrdinalIgnoreCase }, - new object[] { "en-US", GenerateInputString('A', 1000, 'G', 500), GenerateInputString('A', 1000, 'G', 500), CompareOptions.None }, - new object[] { "en-US", GenerateInputString('\u3060', 1000, 'x', 500), GenerateInputString('\u3060', 1000, 'x', 10), CompareOptions.None }, - new object[] { "es-ES", GenerateInputString('\u3060', 100, '\u3059', 50), GenerateInputString('\u3060', 100, '\u3059', 50), CompareOptions.Ordinal }, - new object[] { "tr-TR", GenerateInputString('\u3060', 5000, '\u3059', 2501), GenerateInputString('\u3060', 5000, '\u3059', 2500), CompareOptions.Ordinal } - }; - - [Benchmark] - [MemberData(nameof(s_compareTestData))] - public void Compare(string culture, string string1, string string2, CompareOptions options) - { - CompareInfo compareInfo = CultureInfo.GetCultureInfo(culture).CompareInfo; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - compareInfo.Compare(string1, string2, options); - } - } - - public static IEnumerable s_indexTestData = new List - { - new object[] { "", "string1", "string2", CompareOptions.None }, - new object[] { "", "foobardzsdzs", "rddzs", CompareOptions.IgnoreCase }, - new object[] { "en-US", "StrIng", "string", CompareOptions.OrdinalIgnoreCase }, - new object[] { "", "\u3060", "\u305F", CompareOptions.None }, - new object[] { "ja-JP", "ABCDE", "c", CompareOptions.None }, - new object[] { "", "$", "&", CompareOptions.IgnoreSymbols }, - new object[] { "", "More Test's", "Tests", CompareOptions.IgnoreSymbols }, - new object[] { "es-ES", "TestFooBA\u0300R", "FooB\u00C0R", CompareOptions.IgnoreNonSpace }, - new object[] { "en-US", "Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz", "~", CompareOptions.Ordinal }, - new object[] { "en-US", "Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz", "w", CompareOptions.OrdinalIgnoreCase }, - new object[] { "es-ES", "Hello Worldbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbba!", "y", CompareOptions.Ordinal }, - new object[] { "", GenerateInputString('A', 10, '5', 5), "5", CompareOptions.Ordinal }, - new object[] { "", GenerateInputString('A', 100, 'X', 70), "x", CompareOptions.OrdinalIgnoreCase }, - new object[] { "ja-JP", GenerateInputString('A', 100, 'X', 70), "x", CompareOptions.OrdinalIgnoreCase }, - new object[] { "en-US", GenerateInputString('A', 1000, 'X', 500), "X", CompareOptions.None }, - new object[] { "en-US", GenerateInputString('\u3060', 1000, 'x', 500), "x", CompareOptions.None }, - new object[] { "es-ES", GenerateInputString('\u3060', 100, '\u3059', 50), "\u3059", CompareOptions.Ordinal } - }; - - [Benchmark] - [MemberData(nameof(s_indexTestData))] - public void IndexOf(string culture, string source, string value, CompareOptions options) - { - CompareInfo compareInfo = CultureInfo.GetCultureInfo(culture).CompareInfo; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - compareInfo.IndexOf(source, value, options); - } - } - - [Benchmark] - [MemberData(nameof(s_indexTestData))] - public void LastIndexOf(string culture, string source, string value, CompareOptions options) - { - CompareInfo compareInfo = CultureInfo.GetCultureInfo(culture).CompareInfo; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - compareInfo.LastIndexOf(source, value, options); - } - } - - public static IEnumerable s_prefixTestData = new List - { - new object[] { "", "string1", "str", CompareOptions.None }, - new object[] { "", "foobardzsdzs", "FooBarDZ", CompareOptions.IgnoreCase }, - new object[] { "en-US", "StrIng", "str", CompareOptions.OrdinalIgnoreCase }, - new object[] { "", "\u3060", "\u305F", CompareOptions.None }, - new object[] { "ja-JP", "ABCDE", "cd", CompareOptions.None }, - new object[] { "", "$", "&", CompareOptions.IgnoreSymbols }, - new object[] { "", "More's Test's", "More", CompareOptions.IgnoreSymbols }, - new object[] { "es-ES", "TestFooBA\u0300R", "FooB\u00C0R", CompareOptions.IgnoreNonSpace }, - new object[] { "es-ES", "Hello Worldbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbba!", "Hello World", CompareOptions.Ordinal }, - new object[] { "", GenerateInputString('A', 10, '5', 5), "AAAAA", CompareOptions.Ordinal }, - new object[] { "", GenerateInputString('A', 100, 'X', 70), new string('a', 30), CompareOptions.OrdinalIgnoreCase }, - new object[] { "ja-JP", GenerateInputString('A', 100, 'X', 70), new string('a', 70), CompareOptions.OrdinalIgnoreCase }, - new object[] { "en-US", GenerateInputString('A', 1000, 'X', 500), new string('A', 500), CompareOptions.None }, - new object[] { "en-US", GenerateInputString('\u3060', 1000, 'x', 500), new string('\u3060', 30), CompareOptions.None }, - new object[] { "es-ES", GenerateInputString('\u3060', 100, '\u3059', 50), "\u3060text", CompareOptions.Ordinal } - }; - - [Benchmark] - [MemberData(nameof(s_prefixTestData))] - public void IsPrefix(string culture, string source, string prefix, CompareOptions options) - { - CompareInfo compareInfo = CultureInfo.GetCultureInfo(culture).CompareInfo; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - compareInfo.IsPrefix(source, prefix, options); - } - } - - public static IEnumerable s_suffixTestData = new List - { - new object[] { "", "string1", "ing1", CompareOptions.None }, - new object[] { "", "foobardzsdzs", "DZsDzS", CompareOptions.IgnoreCase }, - new object[] { "en-US", "StrIng", "str", CompareOptions.OrdinalIgnoreCase }, - new object[] { "", "\u3060", "\u305F", CompareOptions.IgnoreSymbols }, - new object[] { "ja-JP", "ABCDE", "E", CompareOptions.None }, - new object[] { "", "$", "&", CompareOptions.IgnoreSymbols }, - new object[] { "", "More's Test's", "Test", CompareOptions.IgnoreSymbols }, - new object[] { "es-ES", "TestFooBA\u0300R", "FooB\u00C0R", CompareOptions.IgnoreNonSpace }, - new object[] { "", GenerateInputString('A', 10, '5', 5), "5AAAA", CompareOptions.Ordinal }, - new object[] { "", GenerateInputString('A', 100, 'X', 70), new string('a', 30), CompareOptions.OrdinalIgnoreCase }, - new object[] { "ja-JP", GenerateInputString('A', 100, 'X', 70), "x" + new string('a', 29), CompareOptions.OrdinalIgnoreCase }, - new object[] { "en-US", GenerateInputString('A', 1000, 'X', 100), new string('A', 900), CompareOptions.None }, - new object[] { "en-US", GenerateInputString('\u3060', 1000, 'x', 500), new string('\u3060', 30), CompareOptions.None }, - new object[] { "es-ES", GenerateInputString('\u3060', 100, '\u3059', 50), "\u3060text", CompareOptions.Ordinal } - }; - - [Benchmark] - [MemberData(nameof(s_suffixTestData))] - public void IsSuffix(string culture, string source, string suffix, CompareOptions options) - { - CompareInfo compareInfo = CultureInfo.GetCultureInfo(culture).CompareInfo; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - compareInfo.IsSuffix(source, suffix, options); - } - } - - [Benchmark] - [InlineData("foo")] - [InlineData("Exhibit \u00C0")] - [InlineData("TestFooBA\u0300RnotsolongTELLme")] - [InlineData("More Test's")] - [InlineData("$")] - [InlineData("\u3060")] - [InlineData("Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz")] - public void IsSortable(string text) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - CompareInfo.IsSortable(text); - } - } - } -} diff --git a/src/libraries/System.Globalization/tests/Performance/Perf.CultureInfo.cs b/src/libraries/System.Globalization/tests/Performance/Perf.CultureInfo.cs deleted file mode 100644 index 9b97c592f1db4..0000000000000 --- a/src/libraries/System.Globalization/tests/Performance/Perf.CultureInfo.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Globalization.Tests -{ - public class Perf_CultureInfo - { - [Benchmark] - public void GetCurrentCulture() - { - CultureInfo result; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 40000; i++) - { - result = CultureInfo.CurrentCulture; result = CultureInfo.CurrentCulture; result = CultureInfo.CurrentCulture; - result = CultureInfo.CurrentCulture; result = CultureInfo.CurrentCulture; result = CultureInfo.CurrentCulture; - result = CultureInfo.CurrentCulture; result = CultureInfo.CurrentCulture; result = CultureInfo.CurrentCulture; - } - } - } - - [Benchmark] - public void GetInvariantCulture() - { - CultureInfo result; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 40000; i++) - { - result = CultureInfo.InvariantCulture; result = CultureInfo.InvariantCulture; result = CultureInfo.InvariantCulture; - result = CultureInfo.InvariantCulture; result = CultureInfo.InvariantCulture; result = CultureInfo.InvariantCulture; - result = CultureInfo.InvariantCulture; result = CultureInfo.InvariantCulture; result = CultureInfo.InvariantCulture; - } - } - } - } -} diff --git a/src/libraries/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs b/src/libraries/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs deleted file mode 100644 index cb42532627b6b..0000000000000 --- a/src/libraries/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Globalization.Tests -{ - /// - /// Performance tests for converting DateTime to different CultureInfos - /// - /// Primary methods affected: Parse, ToString - /// - public class Perf_DateTimeCultureInfo - { - private const int innerIterations = 1000; - - [Benchmark] - [InlineData("fr")] - [InlineData("da")] - [InlineData("ja")] - [InlineData("")] - public void ToString(string culturestring) - { - DateTime time = DateTime.Now; - CultureInfo cultureInfo = new CultureInfo(culturestring); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - time.ToString(cultureInfo); time.ToString(cultureInfo); time.ToString(cultureInfo); - time.ToString(cultureInfo); time.ToString(cultureInfo); time.ToString(cultureInfo); - time.ToString(cultureInfo); time.ToString(cultureInfo); time.ToString(cultureInfo); - } - } - } - - [Benchmark] - [InlineData("fr")] - [InlineData("da")] - [InlineData("ja")] - [InlineData("")] - public void Parse(string culturestring) - { - CultureInfo cultureInfo = new CultureInfo(culturestring); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - DateTime.Parse("10/10/2010 12:00:00 AM", cultureInfo); - DateTime.Parse("10/10/2010 12:00:00 AM", cultureInfo); - DateTime.Parse("10/10/2010 12:00:00 AM", cultureInfo); - DateTime.Parse("10/10/2010 12:00:00 AM", cultureInfo); - } - } - } - } -} diff --git a/src/libraries/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs b/src/libraries/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs deleted file mode 100644 index 0328ba079ee04..0000000000000 --- a/src/libraries/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Globalization.Tests -{ - /// - /// Performance tests for converting numbers to different CultureInfos - /// - public class Perf_NumberCultureInfo - { - private const int innerIterations = 1000; - - [Benchmark] - [InlineData("fr")] - [InlineData("da")] - [InlineData("ja")] - [InlineData("")] - public void ToString(string culturestring) - { - double number = 104234.343; - CultureInfo cultureInfo = new CultureInfo(culturestring); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - number.ToString(cultureInfo); number.ToString(cultureInfo); number.ToString(cultureInfo); - number.ToString(cultureInfo); number.ToString(cultureInfo); number.ToString(cultureInfo); - number.ToString(cultureInfo); number.ToString(cultureInfo); number.ToString(cultureInfo); - } - } - } - } -} diff --git a/src/libraries/System.Globalization/tests/Performance/System.Globalization.PerformanceTests.csproj b/src/libraries/System.Globalization/tests/Performance/System.Globalization.PerformanceTests.csproj deleted file mode 100644 index 559fcf6b21720..0000000000000 --- a/src/libraries/System.Globalization/tests/Performance/System.Globalization.PerformanceTests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - {0BA6851E-0E75-453D-9D2A-CEB94E4DE975} - netstandard-Debug;netstandard-Release - - - - - - - - Common\System\PerfUtils.cs - - - - - CharUnicodeInfo\UnicodeData8.0.txt - UnicodeData.8.0.txt - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From c99cd670645383be5234003e0922b671cd0b6a32 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:03:05 +0100 Subject: [PATCH 10/45] remove System.IO.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/a3c640c6abd96e88dad3807a995d16097649ef56 --- src/libraries/System.IO/System.IO.sln | 10 -- .../tests/Performance/Configurations.props | 7 -- .../tests/Performance/Perf.StreamWriter.cs | 116 ------------------ .../System.IO.PerformanceTests.csproj | 21 ---- 4 files changed, 154 deletions(-) delete mode 100644 src/libraries/System.IO/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO/tests/Performance/Perf.StreamWriter.cs delete mode 100644 src/libraries/System.IO/tests/Performance/System.IO.PerformanceTests.csproj diff --git a/src/libraries/System.IO/System.IO.sln b/src/libraries/System.IO/System.IO.sln index 442dad6932788..f851f2b251875 100644 --- a/src/libraries/System.IO/System.IO.sln +++ b/src/libraries/System.IO/System.IO.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Tests", "tests\Sy {07390899-C8F6-4E83-A3A9-6867B8CB46A0} = {07390899-C8F6-4E83-A3A9-6867B8CB46A0} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.PerformanceTests", "tests\Performance\System.IO.PerformanceTests.csproj", "{66AE57BA-B56C-4A1E-ACA6-7C18431D416B}" - ProjectSection(ProjectDependencies) = postProject - {07390899-C8F6-4E83-A3A9-6867B8CB46A0} = {07390899-C8F6-4E83-A3A9-6867B8CB46A0} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO", "src\System.IO.csproj", "{07390899-C8F6-4E83-A3A9-6867B8CB46A0}" ProjectSection(ProjectDependencies) = postProject {88883C57-83BE-4E93-A363-4CFC716F248F} = {88883C57-83BE-4E93-A363-4CFC716F248F} @@ -35,10 +30,6 @@ Global {492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {07390899-C8F6-4E83-A3A9-6867B8CB46A0}.Debug|Any CPU.ActiveCfg = uapaot-Windows_NT-Debug|Any CPU {07390899-C8F6-4E83-A3A9-6867B8CB46A0}.Debug|Any CPU.Build.0 = uapaot-Windows_NT-Debug|Any CPU {07390899-C8F6-4E83-A3A9-6867B8CB46A0}.Release|Any CPU.ActiveCfg = uap-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {492EC54D-D2C4-4B3F-AC1F-646B3F7EBB02} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {07390899-C8F6-4E83-A3A9-6867B8CB46A0} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {88883C57-83BE-4E93-A363-4CFC716F248F} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.IO/tests/Performance/Configurations.props b/src/libraries/System.IO/tests/Performance/Configurations.props deleted file mode 100644 index d6385a202011f..0000000000000 --- a/src/libraries/System.IO/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - diff --git a/src/libraries/System.IO/tests/Performance/Perf.StreamWriter.cs b/src/libraries/System.IO/tests/Performance/Perf.StreamWriter.cs deleted file mode 100644 index b33202fd45448..0000000000000 --- a/src/libraries/System.IO/tests/Performance/Perf.StreamWriter.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.IO.Tests -{ - public class Perf_StreamWriter - { - [Benchmark(InnerIterationCount = 20000)] - public void Write_Format_OneArg() - { - // Don't want MemoryStream to be expandable to avoid measuring resize - MemoryStream memory = new MemoryStream(new byte[1024 * 1024]); - StreamWriter writer = new StreamWriter(memory); - - foreach (var iteration in Benchmark.Iterations) - { - memory.Position = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - writer.Write("Performance test iteration {0}", i); - } - } - writer.Flush(); - } - } - - [Benchmark(InnerIterationCount = 20000)] - public void Write_Format_OneNoBoxArg() - { - // Don't want MemoryStream to be expandable to avoid measuring resize - MemoryStream memory = new MemoryStream(new byte[1024 * 1024]); - StreamWriter writer = new StreamWriter(memory); - - foreach (var iteration in Benchmark.Iterations) - { - memory.Position = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - writer.Write("Performance test: {0}", nameof(Write_Format_OneNoBoxArg)); - } - } - writer.Flush(); - } - } - - [Benchmark(InnerIterationCount = 20000)] - public void WriteLine_Format_OneArg() - { - // Don't want MemoryStream to be expandable to avoid measuring resize - MemoryStream memory = new MemoryStream(new byte[1024 * 1024]); - StreamWriter writer = new StreamWriter(memory); - - foreach (var iteration in Benchmark.Iterations) - { - memory.Position = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - writer.WriteLine("Performance test iteration {0}", i); - } - } - writer.Flush(); - } - } - - [Benchmark(InnerIterationCount = 20000)] - public void Write_Format_Params() - { - // Don't want MemoryStream to be expandable to avoid measuring resize - MemoryStream memory = new MemoryStream(new byte[1024 * 1024]); - StreamWriter writer = new StreamWriter(memory); - - foreach (var iteration in Benchmark.Iterations) - { - memory.Position = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - writer.Write("Performance test iteration {0}", i, i, i, i, i); - } - } - writer.Flush(); - } - } - - [Benchmark(InnerIterationCount = 20000)] - public void WriteLine_Format_Params() - { - // Don't want MemoryStream to be expandable to avoid measuring resize - MemoryStream memory = new MemoryStream(new byte[1024 * 1024]); - StreamWriter writer = new StreamWriter(memory); - - foreach (var iteration in Benchmark.Iterations) - { - memory.Position = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - writer.WriteLine("Performance test iteration {0}", i, i, i, i, i); - } - } - writer.Flush(); - } - } - } -} diff --git a/src/libraries/System.IO/tests/Performance/System.IO.PerformanceTests.csproj b/src/libraries/System.IO/tests/Performance/System.IO.PerformanceTests.csproj deleted file mode 100644 index 53e9d80accf67..0000000000000 --- a/src/libraries/System.IO/tests/Performance/System.IO.PerformanceTests.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B} - netstandard-Debug;netstandard-Release - - - - Common\System\PerfUtils.cs - - - Common\System\IO\PathFeatures.cs - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 9fdc0cea01afca3eec1717487faad3849d76add0 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:06:04 +0100 Subject: [PATCH 11/45] remove System.IO.Compression.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/3b750cd8eeaa8f402f6676ed4ad90aea809307fe --- .../CompressionStreamPerfTestBase.cs | 71 ------------------- .../System.IO.Compression.sln | 10 --- .../CompressionStreamPerfTests.Deflate.cs | 16 ----- .../CompressionStreamPerfTests.Gzip.cs | 16 ----- .../tests/Performance/Configurations.props | 7 -- ...tem.IO.Compression.PerformanceTests.csproj | 33 --------- 6 files changed, 153 deletions(-) delete mode 100644 src/libraries/Common/tests/System/IO/Compression/CompressionStreamPerfTestBase.cs delete mode 100644 src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Deflate.cs delete mode 100644 src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Gzip.cs delete mode 100644 src/libraries/System.IO.Compression/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO.Compression/tests/Performance/System.IO.Compression.PerformanceTests.csproj diff --git a/src/libraries/Common/tests/System/IO/Compression/CompressionStreamPerfTestBase.cs b/src/libraries/Common/tests/System/IO/Compression/CompressionStreamPerfTestBase.cs deleted file mode 100644 index aaba3178587da..0000000000000 --- a/src/libraries/Common/tests/System/IO/Compression/CompressionStreamPerfTestBase.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.Compression -{ - public abstract class CompressionStreamPerfTestBase : CompressionStreamTestBase - { - public static IEnumerable UncompressedTestFiles_WithCompressionLevel() - { - foreach (CompressionLevel compressionLevel in Enum.GetValues(typeof(CompressionLevel))) - { - foreach (object[] testFile in UncompressedTestFiles()) - { - yield return new object[] { testFile[0], compressionLevel }; - } - } - } - - /// - /// Benchmark tests to measure the performance of individually compressing each file in the - /// Canterbury Corpus - /// - [Benchmark(InnerIterationCount=10)] // limits the max iterations to 100 - [MemberData(nameof(UncompressedTestFiles_WithCompressionLevel))] - public void Compress_Canterbury(string uncompressedFileName, CompressionLevel compressLevel) - { - byte[] bytes = File.ReadAllBytes(uncompressedFileName); - foreach (var iteration in Benchmark.Iterations) - { - // resizing a memory stream during compression will throw off our results, so pre-size it to the - // size of our input - using (MemoryStream compressedDataStream = new MemoryStream(bytes.Length)) - using (iteration.StartMeasurement()) - using (Stream compressor = CreateStream(compressedDataStream, compressLevel)) - compressor.Write(bytes, 0, bytes.Length); - } - } - - /// - /// Benchmark tests to measure the performance of individually compressing each file in the - /// Canterbury Corpus - /// - [Benchmark(InnerIterationCount=100)] - [MemberData(nameof(UncompressedTestFiles))] - public void Decompress_Canterbury(string uncompressedFilePath) - { - int innerIterations = (int)Benchmark.InnerIterationCount; - string compressedFilePath = CompressedTestFile(uncompressedFilePath); - byte[] outputRead = new byte[new FileInfo(uncompressedFilePath).Length]; - MemoryStream[] memories = new MemoryStream[innerIterations]; - foreach (var iteration in Benchmark.Iterations) - { - for (int i = 0; i < innerIterations; i++) - memories[i] = new MemoryStream(File.ReadAllBytes(compressedFilePath)); - - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - using (Stream decompressor = CreateStream(memories[i], CompressionMode.Decompress)) - decompressor.Read(outputRead, 0, outputRead.Length); - - for (int i = 0; i < innerIterations; i++) - memories[i].Dispose(); - } - } - } -} diff --git a/src/libraries/System.IO.Compression/System.IO.Compression.sln b/src/libraries/System.IO.Compression/System.IO.Compression.sln index 51fc1c95370e2..56dddb143ffb8 100644 --- a/src/libraries/System.IO.Compression/System.IO.Compression.sln +++ b/src/libraries/System.IO.Compression/System.IO.Compression.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.Tests {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} = {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.PerformanceTests", "tests\Performance\System.IO.Compression.PerformanceTests.csproj", "{13C0F956-FB7B-4882-A411-39B8E22463D2}" - ProjectSection(ProjectDependencies) = postProject - {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} = {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression", "src\System.IO.Compression.csproj", "{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}" ProjectSection(ProjectDependencies) = postProject {7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43} = {7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43} @@ -35,10 +30,6 @@ Global {17DA7FB5-4370-4385-9A02-FFEF9F482903}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {17DA7FB5-4370-4385-9A02-FFEF9F482903}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {17DA7FB5-4370-4385-9A02-FFEF9F482903}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {13C0F956-FB7B-4882-A411-39B8E22463D2}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {13C0F956-FB7B-4882-A411-39B8E22463D2}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {13C0F956-FB7B-4882-A411-39B8E22463D2}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {13C0F956-FB7B-4882-A411-39B8E22463D2}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {17DA7FB5-4370-4385-9A02-FFEF9F482903} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {13C0F956-FB7B-4882-A411-39B8E22463D2} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Deflate.cs b/src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Deflate.cs deleted file mode 100644 index feb6b5c51cd15..0000000000000 --- a/src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Deflate.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.IO.Compression -{ - public class DeflateStreamPerfTests : CompressionStreamPerfTestBase - { - public override Stream CreateStream(Stream stream, CompressionMode mode) => new DeflateStream(stream, mode); - public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new DeflateStream(stream, mode, leaveOpen); - public override Stream CreateStream(Stream stream, CompressionLevel level) => new DeflateStream(stream, level); - public override Stream CreateStream(Stream stream, CompressionLevel level, bool leaveOpen) => new DeflateStream(stream, level, leaveOpen); - public override Stream BaseStream(Stream stream) => ((DeflateStream)stream).BaseStream; - protected override string CompressedTestFile(string uncompressedPath) => Path.Combine("DeflateTestData", Path.GetFileName(uncompressedPath)); - } -} diff --git a/src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Gzip.cs b/src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Gzip.cs deleted file mode 100644 index 9bf7fdb967e66..0000000000000 --- a/src/libraries/System.IO.Compression/tests/Performance/CompressionStreamPerfTests.Gzip.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.IO.Compression -{ - public class GzipStreamPerfTests : CompressionStreamPerfTestBase - { - public override Stream CreateStream(Stream stream, CompressionMode mode) => new GZipStream(stream, mode); - public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new GZipStream(stream, mode, leaveOpen); - public override Stream CreateStream(Stream stream, CompressionLevel level) => new GZipStream(stream, level); - public override Stream CreateStream(Stream stream, CompressionLevel level, bool leaveOpen) => new GZipStream(stream, level, leaveOpen); - public override Stream BaseStream(Stream stream) => ((GZipStream)stream).BaseStream; - protected override string CompressedTestFile(string uncompressedPath) => Path.Combine("GZipTestData", Path.GetFileName(uncompressedPath) + ".gz"); - } -} diff --git a/src/libraries/System.IO.Compression/tests/Performance/Configurations.props b/src/libraries/System.IO.Compression/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.IO.Compression/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.IO.Compression/tests/Performance/System.IO.Compression.PerformanceTests.csproj b/src/libraries/System.IO.Compression/tests/Performance/System.IO.Compression.PerformanceTests.csproj deleted file mode 100644 index b95b81aa180af..0000000000000 --- a/src/libraries/System.IO.Compression/tests/Performance/System.IO.Compression.PerformanceTests.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - {13C0F956-FB7B-4882-A411-39B8E22463D2} - netstandard-Debug;netstandard-Release - - - - - - Common\System\IO\Compression\LocalMemoryStream.cs - - - Common\System\IO\Compression\StreamHelpers.cs - - - Common\System\IO\Compression\CompressionStreamTestBase.cs - - - Common\System\IO\Compression\CompressionStreamPerfTestBase.cs - - - - - %(RecursiveDir)%(Filename)%(Extension) - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From f511b6f4a4ef9d240c41e1e26a04b53795b98572 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:08:54 +0100 Subject: [PATCH 12/45] remove System.IO.Compression.Brotli.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/78543fbdd621147ad0c14299fd80ecb8f1eb953e --- .../System.IO.Compression.Brotli.sln | 10 -- .../tests/Performance/BrotliPerfTests.cs | 134 ------------------ .../CompressionStreamPerfTests.Brotli.cs | 18 --- .../tests/Performance/Configurations.props | 8 -- ...Compression.Brotli.PerformanceTests.csproj | 27 ---- 5 files changed, 197 deletions(-) delete mode 100644 src/libraries/System.IO.Compression.Brotli/tests/Performance/BrotliPerfTests.cs delete mode 100644 src/libraries/System.IO.Compression.Brotli/tests/Performance/CompressionStreamPerfTests.Brotli.cs delete mode 100644 src/libraries/System.IO.Compression.Brotli/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO.Compression.Brotli/tests/Performance/System.IO.Compression.Brotli.PerformanceTests.csproj diff --git a/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln b/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln index cd4f7d63c4777..92298d174de0e 100644 --- a/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln +++ b/src/libraries/System.IO.Compression.Brotli/System.IO.Compression.Brotli.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.Brotl {5471BFE8-8071-466F-838E-5ADAA779E742} = {5471BFE8-8071-466F-838E-5ADAA779E742} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.Brotli.PerformanceTests", "tests\Performance\System.IO.Compression.Brotli.PerformanceTests.csproj", "{1341F8C8-637A-49A1-BE0F-13867A634929}" - ProjectSection(ProjectDependencies) = postProject - {5471BFE8-8071-466F-838E-5ADAA779E742} = {5471BFE8-8071-466F-838E-5ADAA779E742} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.Brotli", "src\System.IO.Compression.Brotli.csproj", "{5471BFE8-8071-466F-838E-5ADAA779E742}" ProjectSection(ProjectDependencies) = postProject {4ADD9456-A929-4254-B8A2-16FC628ABFDA} = {4ADD9456-A929-4254-B8A2-16FC628ABFDA} @@ -35,10 +30,6 @@ Global {BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {1341F8C8-637A-49A1-BE0F-13867A634929}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU - {1341F8C8-637A-49A1-BE0F-13867A634929}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU - {1341F8C8-637A-49A1-BE0F-13867A634929}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU - {1341F8C8-637A-49A1-BE0F-13867A634929}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU {5471BFE8-8071-466F-838E-5ADAA779E742}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {5471BFE8-8071-466F-838E-5ADAA779E742}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {5471BFE8-8071-466F-838E-5ADAA779E742}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {BC2E1649-291D-412E-9529-EDDA94FA7AD6} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {1341F8C8-637A-49A1-BE0F-13867A634929} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {5471BFE8-8071-466F-838E-5ADAA779E742} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {4ADD9456-A929-4254-B8A2-16FC628ABFDA} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.IO.Compression.Brotli/tests/Performance/BrotliPerfTests.cs b/src/libraries/System.IO.Compression.Brotli/tests/Performance/BrotliPerfTests.cs deleted file mode 100644 index 938b29177dfbf..0000000000000 --- a/src/libraries/System.IO.Compression.Brotli/tests/Performance/BrotliPerfTests.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.Compression -{ - public class BrotliPerfTests : CompressionTestBase - { - protected override string CompressedTestFile(string uncompressedPath) => Path.Combine("BrotliTestData", Path.GetFileName(uncompressedPath) + ".br"); - - public static IEnumerable UncompressedTestFiles_WithCompressionLevel() - { - foreach (CompressionLevel compressionLevel in Enum.GetValues(typeof(CompressionLevel))) - { - foreach (object[] testFile in UncompressedTestFiles()) - { - yield return new object[] { testFile[0], compressionLevel }; - } - } - } - - [Benchmark(InnerIterationCount=10)] // limits the max iterations to 100 - [MemberData(nameof(UncompressedTestFiles_WithCompressionLevel))] - public void Compress_Canterbury_WithState(string uncompressedFileName, CompressionLevel compressLevel) - { - byte[] bytes = File.ReadAllBytes(uncompressedFileName); - ReadOnlySpan uncompressedData = new ReadOnlySpan(bytes); - int maxCompressedSize = BrotliEncoder.GetMaxCompressedLength(bytes.Length); - byte[] compressedDataArray = new byte[maxCompressedSize]; - int compressLevelBrotli = compressLevel == CompressionLevel.Optimal ? 11 : compressLevel == CompressionLevel.Fastest ? 1 : 0; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - using (BrotliEncoder encoder = new BrotliEncoder(compressLevelBrotli, 22)) - { - Span output = new Span(compressedDataArray); - ReadOnlySpan input = uncompressedData; - while (!input.IsEmpty && !output.IsEmpty) - { - encoder.Compress(input, output, out int bytesConsumed, out int written, isFinalBlock:false); - input = input.Slice(bytesConsumed); - output = output.Slice(written); - } - encoder.Compress(input, output, out int bytesConsumed2, out int written2, isFinalBlock: true); - } - } - } - - [Benchmark(InnerIterationCount=100)] - [MemberData(nameof(UncompressedTestFiles))] - public void Decompress_Canterbury_WithState(string uncompressedFileName) - { - int innerIterations = (int)Benchmark.InnerIterationCount; - byte[] compressedBytes = File.ReadAllBytes(CompressedTestFile(uncompressedFileName)); - ReadOnlySpan compressedData = new ReadOnlySpan(compressedBytes); - List uncompressedDataArrays = new List(innerIterations); - foreach (var iteration in Benchmark.Iterations) - { - for (int i = 0; i < innerIterations; i++) - { - uncompressedDataArrays.Add(new byte[65520]); - } - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - using (BrotliDecoder decoder = new BrotliDecoder()) - { - Span output = new Span(uncompressedDataArrays[i]); - ReadOnlySpan input = compressedData; - while (!input.IsEmpty && !output.IsEmpty) - { - decoder.Decompress(input, output, out int bytesConsumed, out int written); - input = input.Slice(bytesConsumed); - output = output.Slice(written); - } - } - } - } - } - } - - [Benchmark(InnerIterationCount=10)] // limits the max iterations to 100 - [MemberData(nameof(UncompressedTestFiles_WithCompressionLevel))] - public void Compress_Canterbury_WithoutState(string uncompressedFileName, CompressionLevel compressLevel) - { - byte[] bytes = File.ReadAllBytes(uncompressedFileName); - ReadOnlySpan uncompressedData = new ReadOnlySpan(bytes); - int maxCompressedSize = BrotliEncoder.GetMaxCompressedLength(bytes.Length); - byte[] compressedDataArray = new byte[maxCompressedSize]; - int compressLevelBrotli = compressLevel == CompressionLevel.Optimal ? 11 : compressLevel == CompressionLevel.Fastest ? 1 : 0; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Assert.True(BrotliEncoder.TryCompress(uncompressedData, compressedDataArray, out int bytesWritten, compressLevelBrotli, 22)); - } - } - } - - /// - /// The perf tests for the instant decompression aren't exactly indicative of real-world scenarios since they require you to know - /// either the exact figure or the upper bound of the uncompressed size of your given compressed data. - /// - [Benchmark(InnerIterationCount=100)] - [MemberData(nameof(UncompressedTestFiles))] - public void Decompress_Canterbury_WithoutState(string uncompressedFileName) - { - int innerIterations = (int)Benchmark.InnerIterationCount; - byte[] compressedBytes = File.ReadAllBytes(CompressedTestFile(uncompressedFileName)); - ReadOnlySpan compressedData = new ReadOnlySpan(compressedBytes); - int uncompressedSize = (int)new FileInfo(uncompressedFileName).Length; - List uncompressedDataArrays = new List(innerIterations); - foreach (var iteration in Benchmark.Iterations) - { - for (int i = 0; i < innerIterations; i++) - { - uncompressedDataArrays.Add(new byte[uncompressedSize]); - } - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - Assert.True(BrotliDecoder.TryDecompress(compressedData, uncompressedDataArrays[i], out int bytesWritten)); - } - } - } - } - } -} diff --git a/src/libraries/System.IO.Compression.Brotli/tests/Performance/CompressionStreamPerfTests.Brotli.cs b/src/libraries/System.IO.Compression.Brotli/tests/Performance/CompressionStreamPerfTests.Brotli.cs deleted file mode 100644 index 439f23961c472..0000000000000 --- a/src/libraries/System.IO.Compression.Brotli/tests/Performance/CompressionStreamPerfTests.Brotli.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.IO.Compression -{ - public class BrotliStreamPerfTests : CompressionStreamPerfTestBase - { - public override Stream CreateStream(Stream stream, CompressionMode mode) => new BrotliStream(stream, mode); - public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new BrotliStream(stream, mode, leaveOpen); - public override Stream CreateStream(Stream stream, CompressionLevel level) => new BrotliStream(stream, level); - public override Stream CreateStream(Stream stream, CompressionLevel level, bool leaveOpen) => new BrotliStream(stream, level, leaveOpen); - public override Stream BaseStream(Stream stream) => ((BrotliStream)stream).BaseStream; - public override bool FlushCompletes { get => false; } - public override int BufferSize { get => 65520; } - protected override string CompressedTestFile(string uncompressedPath) => Path.Combine("BrotliTestData", Path.GetFileName(uncompressedPath) + ".br"); - } -} diff --git a/src/libraries/System.IO.Compression.Brotli/tests/Performance/Configurations.props b/src/libraries/System.IO.Compression.Brotli/tests/Performance/Configurations.props deleted file mode 100644 index ee16a95ad965e..0000000000000 --- a/src/libraries/System.IO.Compression.Brotli/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp-Unix; - netcoreapp-Windows_NT; - - - diff --git a/src/libraries/System.IO.Compression.Brotli/tests/Performance/System.IO.Compression.Brotli.PerformanceTests.csproj b/src/libraries/System.IO.Compression.Brotli/tests/Performance/System.IO.Compression.Brotli.PerformanceTests.csproj deleted file mode 100644 index 50aefbb2548f5..0000000000000 --- a/src/libraries/System.IO.Compression.Brotli/tests/Performance/System.IO.Compression.Brotli.PerformanceTests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - {1341F8C8-637A-49A1-BE0F-13867A634929} - netcoreapp-Unix-Debug;netcoreapp-Unix-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release - - - - - - Common\System\IO\Compression\CompressionStreamTestBase.cs - - - Common\System\IO\Compression\CompressionStreamPerfTestBase.cs - - - - - %(RecursiveDir)%(Filename)%(Extension) - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 72bb9d9a3098f171c3598e7dda501f2d231d5907 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:09:29 +0100 Subject: [PATCH 13/45] remove System.IO.FileSystem.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/7179d4fe52013723574c9994df4caa3244156a9a --- .../System.IO.FileSystem.sln | 10 -- .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Directory.cs | 145 ------------------ .../tests/Performance/Perf.File.cs | 53 ------- .../tests/Performance/Perf.FileInfo.cs | 29 ---- .../tests/Performance/Perf.FileStream.cs | 142 ----------------- ...stem.IO.FileSystem.PerformanceTests.csproj | 31 ---- 7 files changed, 417 deletions(-) delete mode 100644 src/libraries/System.IO.FileSystem/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO.FileSystem/tests/Performance/Perf.Directory.cs delete mode 100644 src/libraries/System.IO.FileSystem/tests/Performance/Perf.File.cs delete mode 100644 src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileInfo.cs delete mode 100644 src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs delete mode 100644 src/libraries/System.IO.FileSystem/tests/Performance/System.IO.FileSystem.PerformanceTests.csproj diff --git a/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln b/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln index a45c2d23a8ebe..42726a58fee0b 100644 --- a/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln +++ b/src/libraries/System.IO.FileSystem/System.IO.FileSystem.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.FileSystem.Tests" {1B528B61-14F9-4BFC-A79A-F0BDB3339150} = {1B528B61-14F9-4BFC-A79A-F0BDB3339150} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.FileSystem.PerformanceTests", "tests\Performance\System.IO.FileSystem.PerformanceTests.csproj", "{3C42F714-82AF-4A43-9B9C-744DE31B5C5D}" - ProjectSection(ProjectDependencies) = postProject - {1B528B61-14F9-4BFC-A79A-F0BDB3339150} = {1B528B61-14F9-4BFC-A79A-F0BDB3339150} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.FileSystem", "src\System.IO.FileSystem.csproj", "{1B528B61-14F9-4BFC-A79A-F0BDB3339150}" ProjectSection(ProjectDependencies) = postProject {4B15C12E-B6AB-4B05-8ECA-C2E2AEA67482} = {4B15C12E-B6AB-4B05-8ECA-C2E2AEA67482} @@ -35,10 +30,6 @@ Global {F0D49126-6A1C-42D5-9428-4374C868BAF8}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {F0D49126-6A1C-42D5-9428-4374C868BAF8}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {F0D49126-6A1C-42D5-9428-4374C868BAF8}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {3C42F714-82AF-4A43-9B9C-744DE31B5C5D}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {3C42F714-82AF-4A43-9B9C-744DE31B5C5D}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {3C42F714-82AF-4A43-9B9C-744DE31B5C5D}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {3C42F714-82AF-4A43-9B9C-744DE31B5C5D}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {1B528B61-14F9-4BFC-A79A-F0BDB3339150}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {1B528B61-14F9-4BFC-A79A-F0BDB3339150}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {1B528B61-14F9-4BFC-A79A-F0BDB3339150}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {F0D49126-6A1C-42D5-9428-4374C868BAF8} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {3C42F714-82AF-4A43-9B9C-744DE31B5C5D} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {1B528B61-14F9-4BFC-A79A-F0BDB3339150} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {4B15C12E-B6AB-4B05-8ECA-C2E2AEA67482} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.IO.FileSystem/tests/Performance/Configurations.props b/src/libraries/System.IO.FileSystem/tests/Performance/Configurations.props deleted file mode 100644 index d6385a202011f..0000000000000 --- a/src/libraries/System.IO.FileSystem/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - diff --git a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.Directory.cs b/src/libraries/System.IO.FileSystem/tests/Performance/Perf.Directory.cs deleted file mode 100644 index 7a70751425743..0000000000000 --- a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.Directory.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.Tests -{ - public class Perf_Directory : FileSystemTest - { - [Benchmark] - public void GetCurrentDirectory() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 20000; i++) - { - Directory.GetCurrentDirectory(); Directory.GetCurrentDirectory(); Directory.GetCurrentDirectory(); - Directory.GetCurrentDirectory(); Directory.GetCurrentDirectory(); Directory.GetCurrentDirectory(); - Directory.GetCurrentDirectory(); Directory.GetCurrentDirectory(); Directory.GetCurrentDirectory(); - } - } - - [Benchmark] - public void CreateDirectory() - { - foreach (var iteration in Benchmark.Iterations) - { - // Setup - string testFile = GetTestFilePath(); - - // Actual perf testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 20000; i++) - Directory.CreateDirectory(testFile + i); - } - } - - [Benchmark] - public void Exists() - { - // Setup - string testFile = GetTestFilePath(); - Directory.CreateDirectory(testFile); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 20000; i++) - { - Directory.Exists(testFile); Directory.Exists(testFile); Directory.Exists(testFile); - Directory.Exists(testFile); Directory.Exists(testFile); Directory.Exists(testFile); - Directory.Exists(testFile); Directory.Exists(testFile); Directory.Exists(testFile); - } - - // Teardown - Directory.Delete(testFile); - } - - public string GetTestDeepFilePath(int depth) - { - string directory = Path.DirectorySeparatorChar + "a"; - StringBuilder sb = new StringBuilder(depth * 2); - for (int i = 0; i < depth; i++) - { - sb.Append(directory); - } - - return sb.ToString(); - } - - public static TheoryData RecursiveDepthData - { - get - { - var data = new TheoryData(); - data.Add(10, 100); - - // Length of the path can be 260 characters on netfx. - if (AreAllLongPathsAvailable) - { - data.Add(100, 10); - // Most Unix distributions have a maximum path length of 1024 characters (1024 UTF-8 bytes). - if (PlatformDetection.IsWindows) - data.Add(1000, 1); - } - - return data; - } - } - - [Benchmark] - [MemberData(nameof(RecursiveDepthData))] - [OuterLoop("Takes a lot of time to finish")] - public void RecursiveCreateDirectoryTest(int depth, int times) - { - // Setup - string rootDirectory = GetTestFilePath(); - string path = GetTestDeepFilePath(depth); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < times; i++) - { - Directory.CreateDirectory(rootDirectory + Path.DirectorySeparatorChar + i + path); - } - } - // TearDown For each iteration - Directory.Delete(rootDirectory, recursive: true); - } - } - - [Benchmark] - [MemberData(nameof(RecursiveDepthData))] - [OuterLoop("Takes a lot of time to finish")] - public void RecursiveDeleteDirectoryTest(int depth, int times) - { - // Setup - string rootDirectory = GetTestFilePath(); - string path = GetTestDeepFilePath(depth); - - foreach (var iteration in Benchmark.Iterations) - { - // Setup For each Iteration - for (int i = 0; i < times; i++) - { - Directory.CreateDirectory(rootDirectory + Path.DirectorySeparatorChar + i + path); - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < times; i++) - { - Directory.Delete(rootDirectory + Path.DirectorySeparatorChar + i, recursive: true); - } - } - } - // TearDown - Directory.Delete(rootDirectory, recursive: true); - } - } -} diff --git a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.File.cs b/src/libraries/System.IO.FileSystem/tests/Performance/Perf.File.cs deleted file mode 100644 index 2cd64322f5538..0000000000000 --- a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.File.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.IO.Tests -{ - public class Perf_File : FileSystemTest - { - [Benchmark] - public void Exists() - { - // Setup - string testFile = GetTestFilePath(); - File.Create(testFile).Dispose(); - - foreach (var iteration in Benchmark.Iterations) - { - // Actual perf testing - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 20000; i++) - { - File.Exists(testFile); File.Exists(testFile); File.Exists(testFile); - File.Exists(testFile); File.Exists(testFile); File.Exists(testFile); - File.Exists(testFile); File.Exists(testFile); File.Exists(testFile); - } - } - } - - // Teardown - File.Delete(testFile); - } - - [Benchmark] - public void Delete() - { - foreach (var iteration in Benchmark.Iterations) - { - // Setup - string testFile = GetTestFilePath(); - for (int i = 0; i < 10000; i++) - File.Create(testFile + 1).Dispose(); - - // Actual perf testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - File.Delete(testFile + 1); - } - } - } -} diff --git a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileInfo.cs b/src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileInfo.cs deleted file mode 100644 index b9d1919b74773..0000000000000 --- a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.IO.Tests -{ - public class Perf_FileInfo : FileSystemTest - { - [Benchmark] - public void ctor_str() - { - string path = GetTestFilePath(); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 20000; i++) - { - new FileInfo(path); new FileInfo(path); new FileInfo(path); - new FileInfo(path); new FileInfo(path); new FileInfo(path); - new FileInfo(path); new FileInfo(path); new FileInfo(path); - } - } - } - } - } -} diff --git a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs b/src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs deleted file mode 100644 index 454db6d8db011..0000000000000 --- a/src/libraries/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; -using System.Threading.Tasks; -using System.Collections.Generic; - -namespace System.IO.Tests -{ - public class Perf_FileStream : FileSystemTest - { - - private static byte[] CreateBytesToWrite(int size) - { - byte[] bytes = new byte[size]; - new Random(531033).NextBytes(bytes); - return bytes; - } - - private string CreateFile(int size) - { - string filePath = GetTestFilePath(); - byte[] bytes = new byte[size]; - new Random(531033).NextBytes(bytes); - File.WriteAllBytes(filePath, bytes); - return filePath; - } - - /// - /// Yields test data for Read and Write operations. Specifies three parameters: - /// - /// useAsync: Whether the IO should be done asynchronously - /// bufferSize:The size of an individual call. The total number of calls will be equivalent to totalSize / readSize - /// totalSize: The total number of bytes to read from the file - /// - public static IEnumerable ReadWriteTestParameters() - { - // A bufferSize of -1 indicates that the bufferSize should be equal to the totalSize, whatever it may be. - const int DefaultBuffer = 4096; - int[] bufferSizes = new int[] { DefaultBuffer / 8, -1, 1}; - int[] totalSizes = new int[] { 200000, 10000000 }; - - foreach (int bufferSize in bufferSizes) - foreach (int totalSize in totalSizes) - foreach (bool useAsync in new[] { true, false }) - if (!(useAsync && bufferSize == 1)) //no Async versions of ReadByte/WriteByte - yield return new object[] { useAsync, bufferSize == -1 ? totalSize : bufferSize, totalSize }; - } - - /// - /// Test for reading from a file using a FileStream. Makes use of differently sized reads to test the performance - /// impact of using the internal buffer. - /// - /// If the bufferSize == 1, calls ReadByte instead of the traditional Read. - /// - [Benchmark] - [MemberData(nameof(ReadWriteTestParameters))] - public async Task Read(bool useAsync, int bufferSize, int totalSize) - { - byte[] bytes = new byte[bufferSize]; - // Actual file size may be slightly over the desired size due to rounding if totalSize % readSize != 0 - int innerIterations = totalSize / bufferSize; - string filePath = CreateFile(innerIterations * bufferSize); - foreach (var iteration in Benchmark.Iterations) - { - if (useAsync) - { - using (FileStream reader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.Asynchronous)) - using (iteration.StartMeasurement()) - await ReadAsyncCore(reader, innerIterations, bytes); - } - else - { - using (FileStream reader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.None)) - using (iteration.StartMeasurement()) - { - if (bufferSize == 1) - for (int i = 0; i < totalSize; i++) - reader.ReadByte(); - else - for (int i = 0; i < innerIterations; i++) - reader.Read(bytes, 0, bytes.Length); - } - } - } - File.Delete(filePath); - } - - /// - /// Test for writing to a file using a FileStream. Makes use of differently sized writes to test the performance - /// impact of using the internal buffer. - /// - /// If the bufferSize == 1, calls WriteByte instead of the traditional Write. - /// - [Benchmark] - [MemberData(nameof(ReadWriteTestParameters))] - public async Task Write(bool useAsync, int bufferSize, int totalSize) - { - byte[] bytes = CreateBytesToWrite(bufferSize); - // Actual file size may be slightly over the desired size due to rounding if totalSize % bufferSize != 0 - int innerIterations = totalSize / bufferSize; - string filePath = GetTestFilePath(); - foreach (var iteration in Benchmark.Iterations) - { - if (useAsync) - { - using (FileStream writer = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read, 4096, FileOptions.Asynchronous)) - using (iteration.StartMeasurement()) - await WriteAsyncCore(writer, innerIterations, bytes); - } - else - { - using (FileStream writer = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read, 4096, FileOptions.None)) - using (iteration.StartMeasurement()) - { - if (bufferSize == 1) - for (int i = 0; i < totalSize; i++) - writer.WriteByte(bytes[0]); - else - for (int i = 0; i < innerIterations; i++) - writer.Write(bytes, 0, bytes.Length); - } - } - File.Delete(filePath); - } - } - - private static async Task ReadAsyncCore(FileStream reader, int innerIterations, byte[] bytes) - { - for (int i = 0; i < innerIterations; i++) - await reader.ReadAsync(bytes, 0, bytes.Length).ConfigureAwait(false); - } - - private static async Task WriteAsyncCore(FileStream writer, int innerIterations, byte[] bytes) - { - for (int i = 0; i < innerIterations; i++) - await writer.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false); - } - } -} diff --git a/src/libraries/System.IO.FileSystem/tests/Performance/System.IO.FileSystem.PerformanceTests.csproj b/src/libraries/System.IO.FileSystem/tests/Performance/System.IO.FileSystem.PerformanceTests.csproj deleted file mode 100644 index 09359ac1bce65..0000000000000 --- a/src/libraries/System.IO.FileSystem/tests/Performance/System.IO.FileSystem.PerformanceTests.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - {3C42F714-82AF-4A43-9B9C-744DE31B5C5D} - netstandard-Debug;netstandard-Release - - - - - - - - - - - - - - - Common\System\PerfUtils.cs - - - Common\System\IO\PathFeatures.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From f2172d677d6556882afcaa6ff930b08c3467e0b2 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:11:19 +0100 Subject: [PATCH 14/45] remove System.IO.MemoryMappedFiles.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/38933dcf911ac91be89b1bfd205b9c7dd2eb2bda --- .../System.IO.MemoryMappedFiles.sln | 10 ---- .../tests/Performance/Configurations.props | 8 ---- .../Performance/Perf.MemoryMappedFile.cs | 48 ------------------- ....MemoryMappedFiles.PerformanceTests.csproj | 28 ----------- 4 files changed, 94 deletions(-) delete mode 100644 src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs delete mode 100644 src/libraries/System.IO.MemoryMappedFiles/tests/Performance/System.IO.MemoryMappedFiles.PerformanceTests.csproj diff --git a/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln b/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln index 80d4b9b8f5196..9e3fe4e628963 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln +++ b/src/libraries/System.IO.MemoryMappedFiles/System.IO.MemoryMappedFiles.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.MemoryMappedFiles {16EE5522-F387-4C9E-9EF2-B5134B043F37} = {16EE5522-F387-4C9E-9EF2-B5134B043F37} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.MemoryMappedFiles.PerformanceTests", "tests\Performance\System.IO.MemoryMappedFiles.PerformanceTests.csproj", "{41CAE9F4-0FFB-4FD1-9413-039C3C561DEE}" - ProjectSection(ProjectDependencies) = postProject - {16EE5522-F387-4C9E-9EF2-B5134B043F37} = {16EE5522-F387-4C9E-9EF2-B5134B043F37} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.MemoryMappedFiles", "src\System.IO.MemoryMappedFiles.csproj", "{16EE5522-F387-4C9E-9EF2-B5134B043F37}" ProjectSection(ProjectDependencies) = postProject {F2740000-E771-4E54-9287-5A1FDF8872F4} = {F2740000-E771-4E54-9287-5A1FDF8872F4} @@ -35,10 +30,6 @@ Global {9D6F6254-B5A3-40FF-8925-68AA8D1CE933}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU {9D6F6254-B5A3-40FF-8925-68AA8D1CE933}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU {9D6F6254-B5A3-40FF-8925-68AA8D1CE933}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU - {41CAE9F4-0FFB-4FD1-9413-039C3C561DEE}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU - {41CAE9F4-0FFB-4FD1-9413-039C3C561DEE}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU - {41CAE9F4-0FFB-4FD1-9413-039C3C561DEE}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU - {41CAE9F4-0FFB-4FD1-9413-039C3C561DEE}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU {16EE5522-F387-4C9E-9EF2-B5134B043F37}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {16EE5522-F387-4C9E-9EF2-B5134B043F37}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {16EE5522-F387-4C9E-9EF2-B5134B043F37}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {9D6F6254-B5A3-40FF-8925-68AA8D1CE933} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {41CAE9F4-0FFB-4FD1-9413-039C3C561DEE} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {16EE5522-F387-4C9E-9EF2-B5134B043F37} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {F2740000-E771-4E54-9287-5A1FDF8872F4} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Configurations.props b/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Configurations.props deleted file mode 100644 index 2b7db4cef13b0..0000000000000 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netstandard-Unix; - netstandard-Windows_NT; - - - \ No newline at end of file diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs deleted file mode 100644 index 9f9aea80630d8..0000000000000 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.MemoryMappedFiles.Tests -{ - /// - /// Performance tests for the construction and disposal of MemoryMappedFiles of varying sizes - /// - public class Perf_MemoryMappedFile : MemoryMappedFilesTestBase - { - [Benchmark] - [InlineData(10000)] - [InlineData(100000)] - [InlineData(1000000)] - [InlineData(10000000)] - public void CreateNew(int capacity) - { - const int InnerIterations = 1000; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - for (int i = 0; i < InnerIterations; i++) - MemoryMappedFile.CreateNew(null, capacity).Dispose(); - } - } - - [Benchmark] - [InlineData(10000)] - [InlineData(100000)] - [InlineData(1000000)] - [InlineData(10000000)] - public void CreateFromFile(int capacity) - { - // Note that the test results will include the disposal overhead of both the MemoryMappedFile - // as well as the Accessor for it - foreach (var iteration in Benchmark.Iterations) - using (TempFile file = new TempFile(GetTestFilePath(), capacity)) - using (iteration.StartMeasurement()) - using (MemoryMappedFile mmfile = MemoryMappedFile.CreateFromFile(file.Path)) - using (mmfile.CreateViewAccessor(capacity / 4, capacity / 2)) - { } - } - } -} diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/System.IO.MemoryMappedFiles.PerformanceTests.csproj b/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/System.IO.MemoryMappedFiles.PerformanceTests.csproj deleted file mode 100644 index d137ebcec157a..0000000000000 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/Performance/System.IO.MemoryMappedFiles.PerformanceTests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - true - {41CAE9F4-0FFB-4FD1-9413-039C3C561DEE} - netstandard-Unix-Debug;netstandard-Unix-Release;netstandard-Windows_NT-Debug;netstandard-Windows_NT-Release - - - - - - - Common\System\Text\StringBuilderCache.cs - - - Common\System\IO\TempFile.cs - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 9fbfcb437c9ee2438594e7929b9d18b98f63f016 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:18:44 +0100 Subject: [PATCH 15/45] remove System.IO.Pipelines.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/a179a32582ce5e65e112f6ce3742e522b98c1f89 --- .../System.IO.Pipelines.sln | 10 -- .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Pipe.cs | 131 ------------------ ...ystem.IO.Pipelines.PerformanceTests.csproj | 15 -- 4 files changed, 163 deletions(-) delete mode 100644 src/libraries/System.IO.Pipelines/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO.Pipelines/tests/Performance/Perf.Pipe.cs delete mode 100644 src/libraries/System.IO.Pipelines/tests/Performance/System.IO.Pipelines.PerformanceTests.csproj diff --git a/src/libraries/System.IO.Pipelines/System.IO.Pipelines.sln b/src/libraries/System.IO.Pipelines/System.IO.Pipelines.sln index fbff0b541714a..cc8c4cbdb8929 100644 --- a/src/libraries/System.IO.Pipelines/System.IO.Pipelines.sln +++ b/src/libraries/System.IO.Pipelines/System.IO.Pipelines.sln @@ -20,11 +20,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E89 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipelines.PerformanceTests", "tests\Performance\System.IO.Pipelines.PerformanceTests.csproj", "{66AE57BA-B56C-4A1E-ACA6-7C18431D416B}" - ProjectSection(ProjectDependencies) = postProject - {1032D5F6-5AE7-4002-A0E4-FEBEADFEA977} = {1032D5F6-5AE7-4002-A0E4-FEBEADFEA977} - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,10 +38,6 @@ Global {9C524CA0-92FF-437B-B568-BCE8A794A69A}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {9C524CA0-92FF-437B-B568-BCE8A794A69A}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {9C524CA0-92FF-437B-B568-BCE8A794A69A}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -55,7 +46,6 @@ Global {9E984EB2-827E-4029-9647-FB5F8B67C553} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {1032D5F6-5AE7-4002-A0E4-FEBEADFEA977} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {9C524CA0-92FF-437B-B568-BCE8A794A69A} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4FA21728-5B35-4F75-9A77-2AC4A5FC5D22} diff --git a/src/libraries/System.IO.Pipelines/tests/Performance/Configurations.props b/src/libraries/System.IO.Pipelines/tests/Performance/Configurations.props deleted file mode 100644 index d6385a202011f..0000000000000 --- a/src/libraries/System.IO.Pipelines/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - diff --git a/src/libraries/System.IO.Pipelines/tests/Performance/Perf.Pipe.cs b/src/libraries/System.IO.Pipelines/tests/Performance/Perf.Pipe.cs deleted file mode 100644 index 8112a48ee4410..0000000000000 --- a/src/libraries/System.IO.Pipelines/tests/Performance/Perf.Pipe.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; - -namespace System.IO.Pipelines.Tests -{ - public sealed class Perf_Pipe - { - private const int InnerIterationCount = 10_000; - - [Benchmark(InnerIterationCount = InnerIterationCount)] - public async void SyncReadAsync() - { - // Setup - var pipe = new Pipe(new PipeOptions(pool: null, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false)); - - PipeWriter writer = pipe.Writer; - PipeReader reader = pipe.Reader; - - await writer.WriteAsync(new ReadOnlyMemory(new byte[] { 0, 0, 0, 0 })); - await writer.FlushAsync(); - - // Actual perf testing - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadResult result = await reader.ReadAsync(); - reader.AdvanceTo(result.Buffer.Start); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerIterationCount)] - public async void ReadAsync() - { - // Setup - var pipe = new Pipe(new PipeOptions(pool: null, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false)); - - PipeWriter writer = pipe.Writer; - PipeReader reader = pipe.Reader; - - var data = new byte[] { 0 }; - - // Actual perf testing - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ValueTask task = reader.ReadAsync(); - - await writer.WriteAsync(data); - await writer.FlushAsync(); - - ReadResult result = await task; - reader.AdvanceTo(result.Buffer.End); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerIterationCount)] - public async void SyncReadAsyncWithCancellationToken() - { - // Setup - var pipe = new Pipe(new PipeOptions(pool: null, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false)); - - PipeWriter writer = pipe.Writer; - PipeReader reader = pipe.Reader; - CancellationTokenSource cts = new CancellationTokenSource(); - - await writer.WriteAsync(new ReadOnlyMemory(new byte[] { 0, 0, 0, 0 })); - await writer.FlushAsync(); - - // Actual perf testing - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadResult result = await reader.ReadAsync(cts.Token); - reader.AdvanceTo(result.Buffer.Start); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerIterationCount)] - public async void ReadAsyncWithCancellationToken() - { - // Setup - var pipe = new Pipe(new PipeOptions(pool: null, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false)); - - PipeWriter writer = pipe.Writer; - PipeReader reader = pipe.Reader; - - var data = new byte[] { 0 }; - - CancellationTokenSource cts = new CancellationTokenSource(); - - // Actual perf testing - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ValueTask task = reader.ReadAsync(cts.Token); - - await writer.WriteAsync(data); - await writer.FlushAsync(); - - ReadResult result = await task; - reader.AdvanceTo(result.Buffer.End); - } - } - } - } - - } -} diff --git a/src/libraries/System.IO.Pipelines/tests/Performance/System.IO.Pipelines.PerformanceTests.csproj b/src/libraries/System.IO.Pipelines/tests/Performance/System.IO.Pipelines.PerformanceTests.csproj deleted file mode 100644 index a36b09e522439..0000000000000 --- a/src/libraries/System.IO.Pipelines/tests/Performance/System.IO.Pipelines.PerformanceTests.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - {66AE57BA-B56C-4A1E-ACA6-7C18431D416B} - netstandard-Debug;netstandard-Release - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - From 1d119ecd19754c80fef4af870fd3534714203cb4 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:20:05 +0100 Subject: [PATCH 16/45] remove System.IO.Pipes.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/719e3f457b031e9cc743ea2bcb59dcafbfe4e22c --- .../System.IO.Pipes/System.IO.Pipes.sln | 10 --- .../tests/Performance/Configurations.props | 7 -- .../Performance/Perf.AnonymousPipeStream.cs | 31 --------- .../tests/Performance/Perf.NamedPipeStream.cs | 67 ------------------- .../tests/Performance/Perf.PipeTest.cs | 34 ---------- .../System.IO.Pipes.PerformanceTests.csproj | 22 ------ 6 files changed, 171 deletions(-) delete mode 100644 src/libraries/System.IO.Pipes/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs delete mode 100644 src/libraries/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs delete mode 100644 src/libraries/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs delete mode 100644 src/libraries/System.IO.Pipes/tests/Performance/System.IO.Pipes.PerformanceTests.csproj diff --git a/src/libraries/System.IO.Pipes/System.IO.Pipes.sln b/src/libraries/System.IO.Pipes/System.IO.Pipes.sln index fca4fe95a949b..e8bd0dfe9a735 100644 --- a/src/libraries/System.IO.Pipes/System.IO.Pipes.sln +++ b/src/libraries/System.IO.Pipes/System.IO.Pipes.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes.Tests", "te {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918} = {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes.PerformanceTests", "tests\Performance\System.IO.Pipes.PerformanceTests.csproj", "{7A8B72D7-FACD-4E96-8390-F2D2FE269687}" - ProjectSection(ProjectDependencies) = postProject - {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918} = {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipes", "src\System.IO.Pipes.csproj", "{D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918}" ProjectSection(ProjectDependencies) = postProject {38B2B275-FB29-45C6-9E68-9ECEBC6BD874} = {38B2B275-FB29-45C6-9E68-9ECEBC6BD874} @@ -35,10 +30,6 @@ Global {142469EC-D665-4FE2-845A-FDA69F9CC557}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {142469EC-D665-4FE2-845A-FDA69F9CC557}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {142469EC-D665-4FE2-845A-FDA69F9CC557}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {7A8B72D7-FACD-4E96-8390-F2D2FE269687}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {7A8B72D7-FACD-4E96-8390-F2D2FE269687}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {7A8B72D7-FACD-4E96-8390-F2D2FE269687}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {7A8B72D7-FACD-4E96-8390-F2D2FE269687}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {142469EC-D665-4FE2-845A-FDA69F9CC557} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {7A8B72D7-FACD-4E96-8390-F2D2FE269687} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {D293A0E4-AE6C-4DF7-99AE-CC1A37BF4918} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {38B2B275-FB29-45C6-9E68-9ECEBC6BD874} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.IO.Pipes/tests/Performance/Configurations.props b/src/libraries/System.IO.Pipes/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.IO.Pipes/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs b/src/libraries/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs deleted file mode 100644 index 8d7de6bce68d2..0000000000000 --- a/src/libraries/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.Pipes.Tests -{ - public class Perf_AnonymousPipeStream_ServerIn_ClientOut : Perf_PipeTest - { - protected override ServerClientPair CreateServerClientPair() - { - ServerClientPair ret = new ServerClientPair(); - ret.readablePipe = new AnonymousPipeServerStream(PipeDirection.In); - ret.writeablePipe = new AnonymousPipeClientStream(PipeDirection.Out, ((AnonymousPipeServerStream)ret.readablePipe).ClientSafePipeHandle); - return ret; - } - } - - public class Perf_AnonymousPipeStream_ServerOut_ClientIn : Perf_PipeTest - { - protected override ServerClientPair CreateServerClientPair() - { - ServerClientPair ret = new ServerClientPair(); - ret.writeablePipe = new AnonymousPipeServerStream(PipeDirection.Out); - ret.readablePipe = new AnonymousPipeClientStream(PipeDirection.In, ((AnonymousPipeServerStream)ret.writeablePipe).ClientSafePipeHandle); - return ret; - } - } -} diff --git a/src/libraries/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs b/src/libraries/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs deleted file mode 100644 index e75a78693569d..0000000000000 --- a/src/libraries/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; -using System.Threading.Tasks; - -namespace System.IO.Pipes.Tests -{ - public class Perf_NamedPipeStream_ServerOut_ClientIn : Perf_PipeTest - { - protected override ServerClientPair CreateServerClientPair() - { - ServerClientPair ret = new ServerClientPair(); - string pipeName = GetUniquePipeName(); - var writeablePipe = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); - var readablePipe = new NamedPipeClientStream(".", pipeName, PipeDirection.In, PipeOptions.Asynchronous); - - Task clientConnect = readablePipe.ConnectAsync(); - writeablePipe.WaitForConnection(); - clientConnect.Wait(); - - ret.readablePipe = readablePipe; - ret.writeablePipe = writeablePipe; - return ret; - } - } - - public class Perf_NamedPipeStream_ServerIn_ClientOut : Perf_PipeTest - { - protected override ServerClientPair CreateServerClientPair() - { - ServerClientPair ret = new ServerClientPair(); - string pipeName = GetUniquePipeName(); - var readablePipe = new NamedPipeServerStream(pipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); - var writeablePipe = new NamedPipeClientStream(".", pipeName, PipeDirection.Out, PipeOptions.Asynchronous); - - Task clientConnect = writeablePipe.ConnectAsync(); - readablePipe.WaitForConnection(); - clientConnect.Wait(); - - ret.readablePipe = readablePipe; - ret.writeablePipe = writeablePipe; - return ret; - } - } - - public class Perf_NamedPipeStream_ServerInOut_ClientInOut : Perf_PipeTest - { - protected override ServerClientPair CreateServerClientPair() - { - ServerClientPair ret = new ServerClientPair(); - string pipeName = GetUniquePipeName(); - var readablePipe = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); - var writeablePipe = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous); - - Task clientConnect = writeablePipe.ConnectAsync(); - readablePipe.WaitForConnection(); - clientConnect.Wait(); - - ret.readablePipe = readablePipe; - ret.writeablePipe = writeablePipe; - return ret; - } - } -} diff --git a/src/libraries/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs b/src/libraries/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs deleted file mode 100644 index 9fdd21d6038d6..0000000000000 --- a/src/libraries/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; -using System.Threading.Tasks; - -namespace System.IO.Pipes.Tests -{ - public abstract class Perf_PipeTest : PipeTestBase - { - [Benchmark(Skip = "https://github.com/dotnet/corefx/issues/18290")] - [InlineData(1000000)] - [ActiveIssue(18290, TestPlatforms.AnyUnix)] - public async Task ReadWrite(int size) - { - Random rand = new Random(314); - byte[] sent = new byte[size]; - byte[] received = new byte[size]; - rand.NextBytes(sent); - foreach (var iteration in Benchmark.Iterations) - { - using (ServerClientPair pair = CreateServerClientPair()) - using (iteration.StartMeasurement()) - { - Task write = Task.Run(() => pair.writeablePipe.Write(sent, 0, sent.Length)); - pair.readablePipe.Read(received, 0, size); - await write; - } - } - } - } -} diff --git a/src/libraries/System.IO.Pipes/tests/Performance/System.IO.Pipes.PerformanceTests.csproj b/src/libraries/System.IO.Pipes/tests/Performance/System.IO.Pipes.PerformanceTests.csproj deleted file mode 100644 index 4ae866e4579e8..0000000000000 --- a/src/libraries/System.IO.Pipes/tests/Performance/System.IO.Pipes.PerformanceTests.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - true - {7A8B72D7-FACD-4E96-8390-F2D2FE269687} - netstandard-Debug;netstandard-Release - - - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 7c64c44305eb91e31f2b72319b00d657918e9fee Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:21:42 +0100 Subject: [PATCH 17/45] remove System.Linq.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/76a3ac9973422418809d5e95c681305686a60800 --- src/libraries/System.Linq/System.Linq.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Linq.cs | 271 ------------------ .../tests/Performance/Perf.LinqTestBase.cs | 260 ----------------- .../System.Linq.PerformanceTests.csproj | 19 -- 5 files changed, 567 deletions(-) delete mode 100644 src/libraries/System.Linq/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Linq/tests/Performance/Perf.Linq.cs delete mode 100644 src/libraries/System.Linq/tests/Performance/Perf.LinqTestBase.cs delete mode 100644 src/libraries/System.Linq/tests/Performance/System.Linq.PerformanceTests.csproj diff --git a/src/libraries/System.Linq/System.Linq.sln b/src/libraries/System.Linq/System.Linq.sln index 414321d920bb0..fb87094032f1c 100644 --- a/src/libraries/System.Linq/System.Linq.sln +++ b/src/libraries/System.Linq/System.Linq.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Tests", "tests\ {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1} = {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.PerformanceTests", "tests\Performance\System.Linq.PerformanceTests.csproj", "{28FB26C9-E425-4E50-9D1D-08F34560E86E}" - ProjectSection(ProjectDependencies) = postProject - {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1} = {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq", "src\System.Linq.csproj", "{CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1}" ProjectSection(ProjectDependencies) = postProject {E09DDC3B-0BBC-4275-A9DD-B366F4F02B81} = {E09DDC3B-0BBC-4275-A9DD-B366F4F02B81} @@ -35,10 +30,6 @@ Global {7C70BB15-870B-4946-8098-625DACD645A6}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {7C70BB15-870B-4946-8098-625DACD645A6}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {7C70BB15-870B-4946-8098-625DACD645A6}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {28FB26C9-E425-4E50-9D1D-08F34560E86E}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {28FB26C9-E425-4E50-9D1D-08F34560E86E}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {28FB26C9-E425-4E50-9D1D-08F34560E86E}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {28FB26C9-E425-4E50-9D1D-08F34560E86E}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {7C70BB15-870B-4946-8098-625DACD645A6} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {28FB26C9-E425-4E50-9D1D-08F34560E86E} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {CA488507-3B6E-4494-B7BE-7B4EEEB2C4D1} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {E09DDC3B-0BBC-4275-A9DD-B366F4F02B81} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Linq/tests/Performance/Configurations.props b/src/libraries/System.Linq/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Linq/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Linq/tests/Performance/Perf.Linq.cs b/src/libraries/System.Linq/tests/Performance/Perf.Linq.cs deleted file mode 100644 index f358adb7023c6..0000000000000 --- a/src/libraries/System.Linq/tests/Performance/Perf.Linq.cs +++ /dev/null @@ -1,271 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Linq; -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Linq.Tests -{ - public class Perf_Linq - { - #region Helper Methods - - /// - /// Provides TestInfo data to xunit performance tests - /// - public static IEnumerable IterationSizeWrapperData() - { - int[] iterations = { 1000 }; - int[] sizes = { 100 }; - foreach (int iteration in iterations) - foreach (int size in sizes) - { - yield return new object[] { size, iteration, Perf_LinqTestBase.WrapperType.NoWrap }; - yield return new object[] { size, iteration, Perf_LinqTestBase.WrapperType.IEnumerable }; - yield return new object[] { size, iteration, Perf_LinqTestBase.WrapperType.IReadOnlyCollection }; - yield return new object[] { size, iteration, Perf_LinqTestBase.WrapperType.ICollection }; - } - } - - /// - /// Provides TestInfo data to xunit performance tests - /// - public static IEnumerable IterationSizeWrapperDataNoWrapper() - { - int[] iterations = { 1000 }; - int[] sizes = { 100 }; - foreach (int iteration in iterations) - foreach (int size in sizes) - yield return new object[] { size, iteration }; - } - - private static int[] QuickSortWorstCase(int n) - { - int OddPos(int k) - { - int s = k; - while (s * 2 < n) - s *= 2; - return (n - 1) % s + 1; - } - - int[] a = new int[n]; - for (int x = 1; x <= n; x++) - { - if (x % 2 == 0) - { - a[x / 2 - 1] = x; - } - else if (x == n) - { - a[n / 2] = x; - } - else - { - a[n - OddPos(x)] = x; - } - } - return a; - } - - private class BaseClass - { - public int Value; - } - private class ChildClass : BaseClass - { - public int ChildValue; - } - - #endregion - - #region Perf Tests - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Select(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Select(o => o + 1)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void SelectSelect(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Select(o => o + 1).Select(o => o - 1)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Where(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Where(o => o >= 0)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void WhereWhere(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Where(o => o >= 0).Where(o => o >= -1)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void WhereSelect(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Where(o => o >= 0).Select(o => o + 1)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Cast_ToBaseClass(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Func, IEnumerable> linqApply = col => col.Cast(); - ChildClass val = new ChildClass() { Value = 1, ChildValue = 2 }; - Perf_LinqTestBase.Measure(10, 5, val, wrapType, linqApply); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Cast_SameType(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Func, IEnumerable> linqApply = col => col.Cast(); - int val = 1; - Perf_LinqTestBase.Measure(10, 5, val, wrapType, linqApply); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void OrderBy(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.OrderBy(o => -o)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void OrderByDescending(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.OrderByDescending(o => -o)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void OrderByThenBy(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.OrderBy(o => -o).ThenBy(o => o)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperDataNoWrapper))] - public void Range(int size, int iteration) - { - Perf_LinqTestBase.Measure(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Range(0, size)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperDataNoWrapper))] - public void Repeat(int size, int iteration) - { - Perf_LinqTestBase.Measure(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Repeat(0, size)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Reverse()); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Skip(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Skip(1)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Take(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Take(size - 1)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void SkipTake(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Skip(1).Take(size - 2)); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void ToArray(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - int[] array = Enumerable.Range(0, size).ToArray(); - Perf_LinqTestBase.MeasureMaterializationToArray(Perf_LinqTestBase.Wrap(array, wrapType), iteration); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void ToList(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - int[] array = Enumerable.Range(0, size).ToArray(); - Perf_LinqTestBase.MeasureMaterializationToList(Perf_LinqTestBase.Wrap(array, wrapType), iteration); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void ToDictionary(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) - { - int[] array = Enumerable.Range(0, size).ToArray(); - Perf_LinqTestBase.MeasureMaterializationToDictionary(Perf_LinqTestBase.Wrap(array, wrapType), iteration); - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Contains_ElementNotFound(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) - { - IEnumerable source = Perf_LinqTestBase.Wrap(Enumerable.Range(0, size).ToArray(), wrapType); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterationCount; i++) - { - source.Contains(size + 1); - } - } - } - } - - [Benchmark] - [MemberData(nameof(IterationSizeWrapperData))] - public void Contains_FirstElementMatches(int size, int iterationCount, Perf_LinqTestBase.WrapperType wrapType) - { - IEnumerable source = Perf_LinqTestBase.Wrap(Enumerable.Range(0, size).ToArray(), wrapType); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterationCount; i++) - { - source.Contains(0); - } - } - } - } - - [Benchmark] - public void OrderBy_TakeOne() - { - Perf_LinqTestBase.MeasureIteration(QuickSortWorstCase(10000).OrderBy(i => i).Take(1), 10); - } - - #endregion - } -} diff --git a/src/libraries/System.Linq/tests/Performance/Perf.LinqTestBase.cs b/src/libraries/System.Linq/tests/Performance/Perf.LinqTestBase.cs deleted file mode 100644 index c98b1db214660..0000000000000 --- a/src/libraries/System.Linq/tests/Performance/Perf.LinqTestBase.cs +++ /dev/null @@ -1,260 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; -using Microsoft.Xunit.Performance; - -namespace System.Linq.Tests -{ - /// - /// Classes and methods to unify performance testing logic - /// - public partial class Perf_LinqTestBase - { - public class EnumerableWrapper : IEnumerable - { - private T[] _array; - public EnumerableWrapper(T[] array) { _array = array; } - - public IEnumerator GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - Collections.IEnumerator Collections.IEnumerable.GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - } - - public class ReadOnlyCollectionWrapper : IReadOnlyCollection - { - private T[] _array; - public ReadOnlyCollectionWrapper(T[] array) { _array = array; } - - public int Count { get { return _array.Length; } } - - public IEnumerator GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - Collections.IEnumerator Collections.IEnumerable.GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - } - - public class ReadOnlyListWrapper : IReadOnlyList - { - private T[] _array; - public ReadOnlyListWrapper(T[] array) { _array = array; } - - public int Count { get { return _array.Length; } } - public T this[int index] { get { return _array[index]; } } - - public IEnumerator GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - Collections.IEnumerator Collections.IEnumerable.GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - } - - public class CollectionWrapper : ICollection - { - private T[] _array; - public CollectionWrapper(T[] array) { _array = array; } - - public int Count { get { return _array.Length; } } - public bool IsReadOnly { get { return true; } } - public bool Contains(T item) - { - return Array.IndexOf(_array, item) >= 0; - } - public void CopyTo(T[] array, int arrayIndex) - { - _array.CopyTo(array, arrayIndex); - } - - public void Add(T item) { throw new NotImplementedException(); } - public void Clear() { throw new NotImplementedException(); } - public bool Remove(T item) { throw new NotImplementedException(); } - - public IEnumerator GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - Collections.IEnumerator Collections.IEnumerable.GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - } - - public class ListWrapper : IList - { - private T[] _array; - public ListWrapper(T[] array) { _array = array; } - - public int Count { get { return _array.Length; } } - public bool IsReadOnly { get { return true; } } - public T this[int index] - { - get { return _array[index]; } - set { throw new NotImplementedException(); } - } - public bool Contains(T item) - { - return Array.IndexOf(_array, item) >= 0; - } - public void CopyTo(T[] array, int arrayIndex) - { - _array.CopyTo(array, arrayIndex); - } - public int IndexOf(T item) - { - return Array.IndexOf(_array, item); - } - - public void Add(T item) { throw new NotImplementedException(); } - public void Clear() { throw new NotImplementedException(); } - public bool Remove(T item) { throw new NotImplementedException(); } - public void Insert(int index, T item) { throw new NotImplementedException(); } - public void RemoveAt(int index) { throw new NotImplementedException(); } - - - public IEnumerator GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - Collections.IEnumerator Collections.IEnumerable.GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } - } - - // ============= - - /// - /// Measures the time of iteration over IEnumerable sequence - /// - /// Elements type - /// Sequence - /// Number of passes - public static void MeasureIteration(IEnumerable source, int iterationCount) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterationCount; i++) - { - foreach (var item in source) - { } - } - } - } - } - - /// - /// Measures the time of materialization of IEnumerable sequence to Array - /// - /// Elements type - /// Sequence - /// Number of passes - public static void MeasureMaterializationToArray(IEnumerable source, int iterationCount) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterationCount; i++) - { - source.ToArray(); - } - } - } - } - - /// - /// Measures the time of materialization of IEnumerable sequence to List - /// - /// Elements type - /// Sequence - /// Number of passes - /// Measured time - public static void MeasureMaterializationToList(IEnumerable source, int iterationCount) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterationCount; i++) - { - source.ToList(); - } - } - } - } - - /// - /// Measures the time of materialization of IEnumerable sequence to Dictionary - /// - /// Elements type - /// Sequence - /// Number of passes - public static void MeasureMaterializationToDictionary(IEnumerable source, int iterationCount) - { - int count = 0; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterationCount; i++) - { - source.ToDictionary(key => count++); - } - } - } - } - - // =============== - - public enum WrapperType - { - NoWrap, - IEnumerable, - IReadOnlyCollection, - IReadOnlyList, - ICollection, - IList - } - - /// - /// Wrap array with one of wrapper types - /// - public static IEnumerable Wrap(T[] source, WrapperType wrapperKind) - { - switch (wrapperKind) - { - case WrapperType.NoWrap: - return source; - case WrapperType.IEnumerable: - return new EnumerableWrapper(source); - case WrapperType.ICollection: - return new CollectionWrapper(source); - case WrapperType.IReadOnlyCollection: - return new ReadOnlyCollectionWrapper(source); - case WrapperType.IReadOnlyList: - return new ReadOnlyListWrapper(source); - case WrapperType.IList: - return new ListWrapper(source); - } - - return source; - } - - /// - /// Main method to measure performance. - /// Creates array of Int32 with length 'elementCount', wraps it by one of the wrapper, applies LINQ and measures materialization to Array - /// - public static void Measure(int elementCount, int iterationCount, WrapperType wrapperKind, Func, IEnumerable> applyLINQ) - { - int[] data = Enumerable.Range(0, elementCount).ToArray(); - IEnumerable wrapper = Wrap(data, wrapperKind); - - IEnumerable linqExpr = applyLINQ(wrapper); - MeasureMaterializationToArray(linqExpr, iterationCount); - } - - /// - /// Main method to measure performance. - /// Creates array of TSource with length 'elementCount', wraps it by one of the wrapper, applies LINQ and measures materialization to Array - /// - public static void Measure(int elementCount, int iterationCount, TSource defaultValue, WrapperType wrapperKind, Func, IEnumerable> applyLINQ) - { - TSource[] data = Enumerable.Repeat(defaultValue, elementCount).ToArray(); - IEnumerable wrapper = Wrap(data, wrapperKind); - - IEnumerable linqExpr = applyLINQ(wrapper); - MeasureMaterializationToArray(linqExpr, iterationCount); - } - - // =========== - } -} diff --git a/src/libraries/System.Linq/tests/Performance/System.Linq.PerformanceTests.csproj b/src/libraries/System.Linq/tests/Performance/System.Linq.PerformanceTests.csproj deleted file mode 100644 index 5230ca2d6f93c..0000000000000 --- a/src/libraries/System.Linq/tests/Performance/System.Linq.PerformanceTests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - {28FB26C9-E425-4E50-9D1D-08F34560E86E} - netstandard-Debug;netstandard-Release - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 13861d4240324cccf234241f6f1ea842737b6cf7 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:24:10 +0100 Subject: [PATCH 18/45] remove System.Linq.Parallel.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/db8922d3bded61a74d3fb45a517e3038b014879a --- .../System.Linq.Parallel.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../QueryOperators/Perf.GroupBy.cs | 194 ------------------ .../QueryOperators/Perf.GroupJoin.cs | 169 --------------- .../Performance/QueryOperators/Perf.Join.cs | 180 ---------------- ...stem.Linq.Parallel.PerformanceTests.csproj | 38 ---- 6 files changed, 598 deletions(-) delete mode 100644 src/libraries/System.Linq.Parallel/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupBy.cs delete mode 100644 src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupJoin.cs delete mode 100644 src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.Join.cs delete mode 100644 src/libraries/System.Linq.Parallel/tests/Performance/System.Linq.Parallel.PerformanceTests.csproj diff --git a/src/libraries/System.Linq.Parallel/System.Linq.Parallel.sln b/src/libraries/System.Linq.Parallel/System.Linq.Parallel.sln index 7883a9ff51332..27547131a8031 100644 --- a/src/libraries/System.Linq.Parallel/System.Linq.Parallel.sln +++ b/src/libraries/System.Linq.Parallel/System.Linq.Parallel.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Parallel.Tests" {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD} = {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Parallel.PerformanceTests", "tests\Performance\System.Linq.Parallel.PerformanceTests.csproj", "{11ABE2F8-4FB9-48AC-91AA-D04503059550}" - ProjectSection(ProjectDependencies) = postProject - {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD} = {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Parallel", "src\System.Linq.Parallel.csproj", "{BE28323E-327A-4E0F-B7F9-16AB7EAB59DD}" ProjectSection(ProjectDependencies) = postProject {670405FE-3828-436E-A668-A0F0B88B57A4} = {670405FE-3828-436E-A668-A0F0B88B57A4} @@ -35,10 +30,6 @@ Global {A7074928-82C3-4739-88FE-9B528977950C}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {A7074928-82C3-4739-88FE-9B528977950C}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {A7074928-82C3-4739-88FE-9B528977950C}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {11ABE2F8-4FB9-48AC-91AA-D04503059550}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {11ABE2F8-4FB9-48AC-91AA-D04503059550}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {11ABE2F8-4FB9-48AC-91AA-D04503059550}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {11ABE2F8-4FB9-48AC-91AA-D04503059550}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {A7074928-82C3-4739-88FE-9B528977950C} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {11ABE2F8-4FB9-48AC-91AA-D04503059550} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {BE28323E-327A-4E0F-B7F9-16AB7EAB59DD} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {670405FE-3828-436E-A668-A0F0B88B57A4} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Linq.Parallel/tests/Performance/Configurations.props b/src/libraries/System.Linq.Parallel/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Linq.Parallel/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupBy.cs b/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupBy.cs deleted file mode 100644 index 7408af191dda6..0000000000000 --- a/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupBy.cs +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.Xunit.Performance; - -namespace System.Linq.Parallel.Tests -{ - public sealed class GroupByPerfTestsUnordered : GroupByPerfTests - { - } - - public sealed class GroupByPerfTestsOrdered : GroupByPerfTests - { - protected override ParallelQuery CreateQueryBase(int count) => base.CreateQueryBase(count).AsOrdered(); - } - - public abstract class GroupByPerfTests - { - const int TotalElementCount = 50_000; - const int CrossProductInnerIterationCount = 100; - const int EnumerateGroupInnerIterationCount = 1_000; - - protected virtual ParallelQuery CreateQueryBase(int count) => UnorderedSources.Default(count); - - private ParallelQuery> CreateQuery(int groupCount, int elementsPerGroup) - { - return CreateQuery(groupCount, elementsPerGroup, (key, vals) => KeyValuePair.Create(key, vals.Sum())); - } - - private ParallelQuery> CreateQuery(int groupCount, int elementsPerGroup, Func, KeyValuePair> resultSelector) - { - return CreateQueryBase(groupCount * elementsPerGroup).GroupBy(x => x % groupCount, resultSelector); - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void QueryCreation() - { - QueryCreation(10); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__10() - { - CrossProduct(10); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__25() - { - CrossProduct(25); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__50() - { - CrossProduct(50); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct_100() - { - CrossProduct(100); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct_500() - { - CrossProduct(500); - } - - [Benchmark(InnerIterationCount = EnumerateGroupInnerIterationCount), MeasureGCAllocations] - public void EnumerateGroup__10() - { - EnumerateGroup(10); - } - - [Benchmark(InnerIterationCount = EnumerateGroupInnerIterationCount), MeasureGCAllocations] - public void EnumerateGroup__25() - { - EnumerateGroup(25); - } - - [Benchmark(InnerIterationCount = EnumerateGroupInnerIterationCount), MeasureGCAllocations] - public void EnumerateGroup__50() - { - EnumerateGroup(50); - } - - [Benchmark(InnerIterationCount = EnumerateGroupInnerIterationCount), MeasureGCAllocations] - public void EnumerateGroup_100() - { - EnumerateGroup(100); - } - - [Benchmark(InnerIterationCount = EnumerateGroupInnerIterationCount), MeasureGCAllocations] - public void EnumerateGroup_500() - { - EnumerateGroup(500); - } - - public void QueryCreation(int elementsPerGroup) - { - Debug.Assert(TotalElementCount % elementsPerGroup == 0); - QueryCreation(TotalElementCount / elementsPerGroup, elementsPerGroup); - } - - private static volatile ParallelQuery> _queryCreationResult; - - public void QueryCreation(int groupCount, int elementsPerGroup) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - _queryCreationResult = CreateQuery(groupCount, elementsPerGroup); - } - } - } - } - - public void CrossProduct(int elementsPerGroup) - { - Debug.Assert(TotalElementCount % elementsPerGroup == 0); - CrossProduct(TotalElementCount / elementsPerGroup, elementsPerGroup); - } - - private static volatile int _crossProductResult; - - public void CrossProduct(int groupCount, int elementsPerGroup) - { - ParallelQuery> values = CreateQuery(groupCount, elementsPerGroup); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - _crossProductResult = 0; - foreach (KeyValuePair pair in values) - { - _crossProductResult += pair.Key * pair.Value; - } - } - } - } - } - - public void EnumerateGroup(int elementsPerGroup) - { - Debug.Assert(TotalElementCount % elementsPerGroup == 0); - EnumerateGroup(TotalElementCount / elementsPerGroup, elementsPerGroup); - } - - private static volatile int _enumerateGroupResult; - - public void EnumerateGroup(int groupCount, int elementsPerGroup) - { - int iters = (int)Benchmark.InnerIterationCount; - - ParallelQuery> values = CreateQuery(groupCount, elementsPerGroup, - (key, vals) => - { - int value = 0; - - for (int i = 0; i < iters; i++) - { - value += vals.Sum(); - } - - return KeyValuePair.Create(key, value / iters); - }); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - _enumerateGroupResult = 0; - foreach (KeyValuePair pair in values) - { - _enumerateGroupResult += pair.Key * pair.Value; - } - } - } - } - } -} diff --git a/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupJoin.cs b/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupJoin.cs deleted file mode 100644 index 1a14df5165fbc..0000000000000 --- a/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.GroupJoin.cs +++ /dev/null @@ -1,169 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.Xunit.Performance; - -namespace System.Linq.Parallel.Tests -{ - public sealed class GroupJoinPerfTestsUnorderedLeftUnorderedRight : GroupJoinPerfTests - { - } - - public sealed class GroupJoinPerfTestsUnorderedLeftOrderedRight : GroupJoinPerfTests - { - protected override ParallelQuery CreateRight(int count) => base.CreateRight(count).AsOrdered(); - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__1000() - { - CrossProduct(1000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__2000() - { - CrossProduct(2000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct_10000() - { - CrossProduct(10000); - } - } - - public sealed class GroupJoinPerfTestsOrderedLeftUnorderedRight : GroupJoinPerfTests - { - protected override ParallelQuery CreateLeft(int count) => base.CreateLeft(count).AsOrdered(); - } - - public sealed class GroupJoinPerfTestsOrderedLeftOrderedRight : GroupJoinPerfTests - { - protected override ParallelQuery CreateLeft(int count) => base.CreateLeft(count).AsOrdered(); - protected override ParallelQuery CreateRight(int count) => base.CreateRight(count).AsOrdered(); - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__1000() - { - CrossProduct(1000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__2000() - { - CrossProduct(2000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct_10000() - { - CrossProduct(10000); - } - } - - public abstract class GroupJoinPerfTests - { - const int TotalElementCount = 50_000; - protected const int CrossProductInnerIterationCount = 100; - - protected virtual ParallelQuery CreateLeft(int count) => UnorderedSources.Default(count); - protected virtual ParallelQuery CreateRight(int count) => UnorderedSources.Default(count); - - private ParallelQuery> CreateQuery(int leftCount, int rightsPerLeft) - { - return CreateLeft(leftCount).GroupJoin(CreateRight(leftCount * rightsPerLeft), - x => x, y => y % leftCount, (x, y) => KeyValuePair.Create(x, y.Sum())); - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void QueryCreation() - { - QueryCreation(10); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct____10() - { - CrossProduct(10); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct____25() - { - CrossProduct(25); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct____50() - { - CrossProduct(50); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct___100() - { - CrossProduct(100); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct___500() - { - CrossProduct(500); - } - - public void QueryCreation(int rightsPerLeft) - { - Debug.Assert(TotalElementCount % rightsPerLeft == 0); - QueryCreation(TotalElementCount / rightsPerLeft, rightsPerLeft); - } - - private static volatile ParallelQuery> _queryCreationResult; - - public void QueryCreation(int leftCount, int rightsPerLeft) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - _queryCreationResult = CreateQuery(leftCount, rightsPerLeft); - } - } - } - } - - public void CrossProduct(int rightsPerLeft) - { - Debug.Assert(TotalElementCount % rightsPerLeft == 0); - CrossProduct(TotalElementCount / rightsPerLeft, rightsPerLeft); - } - - private static volatile int _crossProductResult; - - public void CrossProduct(int leftCount, int rightsPerLeft) - { - ParallelQuery> values = CreateQuery(leftCount, rightsPerLeft); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - _crossProductResult = 0; - foreach (KeyValuePair pair in values) - { - _crossProductResult += pair.Key * pair.Value; - } - } - } - } - } - } -} diff --git a/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.Join.cs b/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.Join.cs deleted file mode 100644 index 80bde4b4fe48a..0000000000000 --- a/src/libraries/System.Linq.Parallel/tests/Performance/QueryOperators/Perf.Join.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using Microsoft.Xunit.Performance; - -namespace System.Linq.Parallel.Tests -{ - public sealed class JoinPerfTestsUnorderedLeftUnorderedRight : JoinPerfTests - { - } - - public sealed class JoinPerfTestsUnorderedLeftOrderedRight : JoinPerfTests - { - protected override ParallelQuery CreateRight(int count) => base.CreateRight(count).AsOrdered(); - } - - public sealed class JoinPerfTestsOrderedLeftUnorderedRight : JoinPerfTests - { - protected override ParallelQuery CreateLeft(int count) => base.CreateLeft(count).AsOrdered(); - } - - public sealed class JoinPerfTestsShuffledOrderedLeftUnorderedRight : JoinPerfTests - { - protected override ParallelQuery CreateLeft(int count) => base.CreateLeft(count).OrderBy(x => x); - } - - public sealed class JoinPerfTestsOrderedLeftOrderedRight : JoinPerfTests - { - protected override ParallelQuery CreateLeft(int count) => base.CreateLeft(count).AsOrdered(); - protected override ParallelQuery CreateRight(int count) => base.CreateRight(count).AsOrdered(); - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__1000() - { - CrossProduct(1000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__2000() - { - CrossProduct(2000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct_10000() - { - CrossProduct(10000); - } - } - - public sealed class JoinPerfTestsShuffledOrderedLeftOrderedRight : JoinPerfTests - { - protected override ParallelQuery CreateLeft(int count) => base.CreateLeft(count).OrderBy(x => x); - protected override ParallelQuery CreateRight(int count) => base.CreateRight(count).AsOrdered(); - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__1000() - { - CrossProduct(1000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct__2000() - { - CrossProduct(2000); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct_10000() - { - CrossProduct(10000); - } - } - - public abstract class JoinPerfTests - { - const int TotalElementCount = 50_000; - protected const int CrossProductInnerIterationCount = 100; - - protected virtual ParallelQuery CreateLeft(int count) => UnorderedSources.Default(count); - protected virtual ParallelQuery CreateRight(int count) => UnorderedSources.Default(count); - - private ParallelQuery> CreateQuery(int leftCount, int rightsPerLeft) - { - return CreateLeft(leftCount).Join(CreateRight(leftCount * rightsPerLeft), - x => x, y => y % leftCount, (x, y) => KeyValuePair.Create(x, y)); - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void QueryCreation() - { - QueryCreation(10); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct____10() - { - CrossProduct(10); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct____25() - { - CrossProduct(25); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct____50() - { - CrossProduct(50); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct___100() - { - CrossProduct(100); - } - - [Benchmark(InnerIterationCount = CrossProductInnerIterationCount), MeasureGCAllocations] - public void CrossProduct___500() - { - CrossProduct(500); - } - - public void QueryCreation(int rightsPerLeft) - { - Debug.Assert(TotalElementCount % rightsPerLeft == 0); - QueryCreation(TotalElementCount / rightsPerLeft, rightsPerLeft); - } - - private static volatile ParallelQuery> _queryCreationResult; - - public void QueryCreation(int leftCount, int rightsPerLeft) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - _queryCreationResult = CreateQuery(leftCount, rightsPerLeft); - } - } - } - } - - public void CrossProduct(int rightsPerLeft) - { - Debug.Assert(TotalElementCount % rightsPerLeft == 0); - CrossProduct(TotalElementCount / rightsPerLeft, rightsPerLeft); - } - - private static volatile int _crossProductResult; - - public void CrossProduct(int leftCount, int rightsPerLeft) - { - ParallelQuery> values = CreateQuery(leftCount, rightsPerLeft); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - _crossProductResult = 0; - foreach (KeyValuePair pair in values) - { - _crossProductResult += pair.Key * pair.Value; - } - } - } - } - } - } -} diff --git a/src/libraries/System.Linq.Parallel/tests/Performance/System.Linq.Parallel.PerformanceTests.csproj b/src/libraries/System.Linq.Parallel/tests/Performance/System.Linq.Parallel.PerformanceTests.csproj deleted file mode 100644 index ef24f999547a7..0000000000000 --- a/src/libraries/System.Linq.Parallel/tests/Performance/System.Linq.Parallel.PerformanceTests.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - {11ABE2F8-4FB9-48AC-91AA-D04503059550} - netstandard-Debug;netstandard-Release - - - - Common\System\PerfUtils.cs - - - Helpers\DeliberateTestException.cs - - - Helpers\Enumerables.cs - - - Helpers\KeyValuePair.cs - - - Helpers\Labeled.cs - - - Helpers\Sources.cs - - - Helpers\UnorderedSources.cs - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 7d7d8aac59364c4c0e93ec9e745f96d0ad7f1f14 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:29:43 +0100 Subject: [PATCH 19/45] remove System.Memory.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/fa4b8931f2af745786df18c85c4ea69cb44d106f --- src/libraries/System.Memory/System.Memory.sln | 10 - .../tests/Performance/Configurations.props | 8 - .../Performance/Perf.Base64EncodeDecode.cs | 265 ----- .../tests/Performance/Perf.Memory.Slice.cs | 164 ---- .../tests/Performance/Perf.Memory.Span.cs | 166 ---- .../Perf.ReadOnlySequence.Enumerator.cs | 301 ------ .../Perf.ReadOnlySequence.First.cs | 302 ------ .../Perf.ReadOnlySequence.GetPosition.cs | 215 ---- .../Perf.ReadOnlySequence.Slice.cs | 367 ------- .../Perf.ReadOnlySequence.TryGet.cs | 314 ------ .../Perf.Span.BinaryReadAndWrite.cs | 281 ------ .../Performance/Perf.Span.BinarySearch.cs | 286 ------ .../tests/Performance/Perf.Span.Clear.cs | 94 -- .../tests/Performance/Perf.Span.Contains.cs | 317 ------ .../tests/Performance/Perf.Span.Fill.cs | 52 - .../tests/Performance/Perf.Span.IndexOf.cs | 229 ----- .../tests/Performance/Perf.Span.IndexOfAny.cs | 292 ------ .../Perf.Span.SequenceCompareTo.cs | 190 ---- .../tests/Performance/Perf.Span.StartsWith.cs | 147 --- .../tests/Performance/Perf.Utf8Formatter.cs | 267 ----- .../tests/Performance/Perf.Utf8Parser.cs | 919 ------------------ .../System.Memory.PerformanceTests.csproj | 55 -- 22 files changed, 5241 deletions(-) delete mode 100644 src/libraries/System.Memory/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Base64EncodeDecode.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Memory.Slice.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Memory.Span.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Enumerator.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.First.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.GetPosition.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Slice.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.TryGet.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.BinaryReadAndWrite.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.BinarySearch.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.Contains.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.Fill.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOf.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOfAny.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.SequenceCompareTo.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Span.StartsWith.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Utf8Formatter.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/Perf.Utf8Parser.cs delete mode 100644 src/libraries/System.Memory/tests/Performance/System.Memory.PerformanceTests.csproj diff --git a/src/libraries/System.Memory/System.Memory.sln b/src/libraries/System.Memory/System.Memory.sln index f54ba8d9900d6..786d0a37ec5e8 100644 --- a/src/libraries/System.Memory/System.Memory.sln +++ b/src/libraries/System.Memory/System.Memory.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Memory.Tests", "test {4BBC8F69-D03E-4432-AA8A-D458FA5B235A} = {4BBC8F69-D03E-4432-AA8A-D458FA5B235A} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Memory.PerformanceTests", "tests\Performance\System.Memory.PerformanceTests.csproj", "{18482C55-6B57-41E8-BBC4-383B9E2C7AA2}" - ProjectSection(ProjectDependencies) = postProject - {4BBC8F69-D03E-4432-AA8A-D458FA5B235A} = {4BBC8F69-D03E-4432-AA8A-D458FA5B235A} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Memory", "src\System.Memory.csproj", "{4BBC8F69-D03E-4432-AA8A-D458FA5B235A}" ProjectSection(ProjectDependencies) = postProject {E883935B-D8FD-4FC9-A189-9D9E7F7EF550} = {E883935B-D8FD-4FC9-A189-9D9E7F7EF550} @@ -35,10 +30,6 @@ Global {15DB0DCC-68B4-4CFB-8BD2-F26BCCAF5A3F}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {15DB0DCC-68B4-4CFB-8BD2-F26BCCAF5A3F}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {15DB0DCC-68B4-4CFB-8BD2-F26BCCAF5A3F}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {18482C55-6B57-41E8-BBC4-383B9E2C7AA2}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {18482C55-6B57-41E8-BBC4-383B9E2C7AA2}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {18482C55-6B57-41E8-BBC4-383B9E2C7AA2}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {18482C55-6B57-41E8-BBC4-383B9E2C7AA2}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {4BBC8F69-D03E-4432-AA8A-D458FA5B235A}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {4BBC8F69-D03E-4432-AA8A-D458FA5B235A}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {4BBC8F69-D03E-4432-AA8A-D458FA5B235A}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {15DB0DCC-68B4-4CFB-8BD2-F26BCCAF5A3F} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {18482C55-6B57-41E8-BBC4-383B9E2C7AA2} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {4BBC8F69-D03E-4432-AA8A-D458FA5B235A} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {E883935B-D8FD-4FC9-A189-9D9E7F7EF550} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Memory/tests/Performance/Configurations.props b/src/libraries/System.Memory/tests/Performance/Configurations.props deleted file mode 100644 index f5d3d45ffbf44..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp; - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Base64EncodeDecode.cs b/src/libraries/System.Memory/tests/Performance/Perf.Base64EncodeDecode.cs deleted file mode 100644 index a2e8cbb9130f2..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Base64EncodeDecode.cs +++ /dev/null @@ -1,265 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Text.Tests -{ - public class Base64EncodeDecodeTests - { - private const int InnerCount = 1000; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64Encode(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - Span destination = new byte[Base64.GetMaxEncodedToUtf8Length(numberOfBytes)]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - Base64.EncodeToUtf8(source, destination, out int consumed, out int written); - } - } - - Span backToSource = new byte[numberOfBytes]; - Base64.DecodeFromUtf8(destination, backToSource, out _, out _); - Assert.True(source.SequenceEqual(backToSource)); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64EncodeDestinationTooSmall(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - Span destination = new byte[Base64.GetMaxEncodedToUtf8Length(numberOfBytes) - 1]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - Base64.EncodeToUtf8(source, destination, out int consumed, out int written); - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64EncodeBaseline(int numberOfBytes) - { - var source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source.AsSpan()); - var destination = new char[Base64.GetMaxEncodedToUtf8Length(numberOfBytes)]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - Convert.ToBase64CharArray(source, 0, source.Length, destination, 0); - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64Decode(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - Span encoded = new byte[Base64.GetMaxEncodedToUtf8Length(numberOfBytes)]; - Base64.EncodeToUtf8(source, encoded, out _, out _); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - Base64.DecodeFromUtf8(encoded, source, out int bytesConsumed, out int bytesWritten); - } - } - - Span backToEncoded = encoded.ToArray(); - Base64.EncodeToUtf8(source, encoded, out _, out _); - Assert.True(backToEncoded.SequenceEqual(encoded)); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64DecodeDetinationTooSmall(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - Span encoded = new byte[Base64.GetMaxEncodedToUtf8Length(numberOfBytes)]; - Base64.EncodeToUtf8(source, encoded, out _, out _); - - source = source.Slice(0, source.Length - 1); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - Base64.DecodeFromUtf8(encoded, source, out int bytesConsumed, out int bytesWritten); - } - } - } - -#if netcoreapp - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64DecodeBaseline(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - ReadOnlySpan encoded = Convert.ToBase64String(source.ToArray()).ToCharArray(); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - Convert.TryFromBase64Chars(encoded, source, out int bytesWritten); - } - } - } -#endif - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64EncodeInPlace(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - int length = Base64.GetMaxEncodedToUtf8Length(numberOfBytes); - Span decodedSpan = new byte[length]; - source.CopyTo(decodedSpan); - Span backupSpan = decodedSpan.ToArray(); - - int bytesWritten = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - backupSpan.CopyTo(decodedSpan); - Base64.EncodeToUtf8InPlace(decodedSpan, numberOfBytes, out bytesWritten); - } - } - } - - Span backToSource = new byte[numberOfBytes]; - Base64.DecodeFromUtf8(decodedSpan, backToSource, out _, out _); - Assert.True(backupSpan.Slice(0, numberOfBytes).SequenceEqual(backToSource)); - } - - [Benchmark] - [InlineData(1000 * 1000)] - private static void Base64EncodeInPlaceOnce(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - int length = Base64.GetMaxEncodedToUtf8Length(numberOfBytes); - Span decodedSpan = new byte[length]; - source.CopyTo(decodedSpan); - Span backupSpan = decodedSpan.ToArray(); - - int bytesWritten = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - backupSpan.CopyTo(decodedSpan); - using (iteration.StartMeasurement()) - { - Base64.EncodeToUtf8InPlace(decodedSpan, numberOfBytes, out bytesWritten); - } - } - - Span backToSource = new byte[numberOfBytes]; - Base64.DecodeFromUtf8(decodedSpan, backToSource, out _, out _); - Assert.True(backupSpan.Slice(0, numberOfBytes).SequenceEqual(backToSource)); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Base64DecodeInPlace(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - int length = Base64.GetMaxEncodedToUtf8Length(numberOfBytes); - Span encodedSpan = new byte[length]; - Base64.EncodeToUtf8(source, encodedSpan, out _, out _); - - Span backupSpan = encodedSpan.ToArray(); - - int bytesWritten = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - backupSpan.CopyTo(encodedSpan); - Base64.DecodeFromUtf8InPlace(encodedSpan, out bytesWritten); - } - } - } - - Assert.True(source.SequenceEqual(encodedSpan.Slice(0, bytesWritten))); - } - - [Benchmark] - [InlineData(1000 * 1000)] - private static void Base64DecodeInPlaceOnce(int numberOfBytes) - { - Span source = new byte[numberOfBytes]; - Base64TestHelper.InitalizeBytes(source); - int length = Base64.GetMaxEncodedToUtf8Length(numberOfBytes); - Span encodedSpan = new byte[length]; - - int bytesWritten = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - Base64.EncodeToUtf8(source, encodedSpan, out _, out _); - using (iteration.StartMeasurement()) - { - Base64.DecodeFromUtf8InPlace(encodedSpan, out bytesWritten); - } - } - - Assert.True(source.SequenceEqual(encodedSpan.Slice(0, bytesWritten))); - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Memory.Slice.cs b/src/libraries/System.Memory/tests/Performance/Perf.Memory.Slice.cs deleted file mode 100644 index f12c371c57794..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Memory.Slice.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class MemorySlice - { - private const int InnerCount = 1000; - volatile static int s_volatileInt = 0; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Memory_Byte_SliceThenGetSpan(int numberOfBytes) - { - Memory memory = new byte[numberOfBytes]; - int numberOfSlices = numberOfBytes / 10 - 1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < numberOfSlices; j++) - { - Span span = memory.Slice(10, 1).Span; - localInt ^= span[0]; - } - } - } - s_volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void Memory_Byte_GetSpanThenSlice(int numberOfBytes) - { - Memory memory = new byte[numberOfBytes]; - int numberOfSlices = numberOfBytes / 10 - 1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < numberOfSlices; j++) - { - Span span = memory.Span.Slice(10, 1); - localInt ^= span[0]; - } - } - } - s_volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void ReadOnlyMemory_Byte_GetSpanThenSlice(int numberOfBytes) - { - ReadOnlyMemory memory = new byte[numberOfBytes]; - int numberOfSlices = numberOfBytes / 10 - 1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - for (int j = 0; j < numberOfSlices; j++) - { - ReadOnlySpan span = memory.Span.Slice(10, 1); - localInt ^= span[0]; - } - } - } - s_volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1000)] - [InlineData(1000 * 1000)] - private static void ReadOnlyMemory_Char_GetSpanThenSlice(int numberOfChars) - { - ReadOnlyMemory memory = new char[numberOfChars]; - int numberOfSlices = numberOfChars / 10 - 1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - for (int j = 0; j < numberOfSlices; j++) - { - ReadOnlySpan span = memory.Span.Slice(10, 1); - localInt ^= span[0]; - } - } - } - s_volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void ReadOnlyMemory_Byte_TryGetArray() - { - ReadOnlyMemory memory = new byte[1]; - ArraySegment result = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - MemoryMarshal.TryGetArray(memory, out result); - } - } - } - - s_volatileInt = result.Count; - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void ReadOnlyMemory_Char_TryGetArray() - { - ReadOnlyMemory memory = new char[1]; - ArraySegment result = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - MemoryMarshal.TryGetArray(memory, out result); - } - } - } - - s_volatileInt = result.Count; - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Memory.Span.cs b/src/libraries/System.Memory/tests/Performance/Perf.Memory.Span.cs deleted file mode 100644 index f2db92e0f4cf2..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Memory.Span.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Buffers; -using System.MemoryTests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Memory_Span - { - private const int InnerCount = 1_000_000; - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromDefaultIntegerMemory() - { - Memory memory = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromIntegerArrayBackedMemory() - { - int[] a = { 91, 92, -93, 94 }; - var memory = new Memory(a); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromCharArrayBackedMemory() - { - char[] a = "9192-9394".ToCharArray(); - var memory = new Memory(a); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromObjectArrayBackedMemory() - { - object o1 = new object(); - object o2 = new object(); - object[] a = { o1, o2 }; - var memory = new Memory(a); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromStringBackedMemory() - { - string a = "9192-9394"; - ReadOnlyMemory memory = a.AsMemory(); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlySpan span = memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromIntegerMemoryManager() - { - int[] a = { 91, 92, -93, 94 }; - var memory = new Memory(a); - MemoryManager manager = new CustomMemoryForTest(a); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = manager.Memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromCharMemoryManager() - { - char[] a = "9192-9394".ToCharArray(); - var memory = new Memory(a); - MemoryManager manager = new CustomMemoryForTest(a); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = manager.Memory.Span; - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - public static void SpanFromObjectMemoryManager() - { - object o1 = new object(); - object o2 = new object(); - object[] a = { o1, o2 }; - var memory = new Memory(a); - MemoryManager manager = new CustomMemoryForTest(a); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Span span = manager.Memory.Span; - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Enumerator.cs b/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Enumerator.cs deleted file mode 100644 index 4d6d45c188dad..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Enumerator.cs +++ /dev/null @@ -1,301 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Memory.Tests; -using System.MemoryTests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Tests -{ - public class Perf_ReadOnlySequence_Enumerator - { - private const int InnerCount = 100_000; - volatile static int _volatileInt = 0; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Memory(int bufSize, int bufOffset) - { - var manager = new CustomMemoryForTest(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(manager.Memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_SingleSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment1, bufSize - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount / 10)] - [InlineData(10_000, 100)] - private static void Byte_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new byte[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Byte_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Byte_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new char[bufSize], bufOffset, bufSize - 2 * bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_Memory(int bufSize, int bufOffset) - { - var manager = new CustomMemoryForTest(new char[bufSize], bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(manager.Memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_SingleSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment1, bufSize - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount / 10)] - [InlineData(10_000, 100)] - private static void Char_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new char[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void String(int bufSize, int bufOffset) - { - ReadOnlyMemory strMemory = new string('a', bufSize).AsMemory(); - strMemory = strMemory.Slice(bufOffset, bufSize - bufOffset); - var buffer = new ReadOnlySequence(strMemory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Char_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Char_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - foreach(ReadOnlyMemory memory in buffer) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.First.cs b/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.First.cs deleted file mode 100644 index 3d5b69e1bf677..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.First.cs +++ /dev/null @@ -1,302 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Memory.Tests; -using System.MemoryTests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Tests -{ - public class Perf_ReadOnlySequence_First - { - private const int InnerCount = 100_000; - volatile static int _volatileInt = 0; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Memory(int bufSize, int bufOffset) - { - var manager = new CustomMemoryForTest(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(manager.Memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_SingleSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment1, bufSize - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new byte[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Byte_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Byte_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new char[bufSize], bufOffset, bufSize - 2 * bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_Memory(int bufSize, int bufOffset) - { - var manager = new CustomMemoryForTest(new char[bufSize], bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(manager.Memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_SingleSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment1, bufSize - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new char[bufSize / 10]); - - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void String(int bufSize, int bufOffset) - { - ReadOnlyMemory memory = new string('a', bufSize).AsMemory(); - memory = memory.Slice(bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Char_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Char_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlyMemory first = buffer.First; - localInt ^= first.Length; - } - } - _volatileInt = localInt; - } - } - - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.GetPosition.cs b/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.GetPosition.cs deleted file mode 100644 index 17cfb18cc33f6..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.GetPosition.cs +++ /dev/null @@ -1,215 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Memory.Tests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Tests -{ - public class Rerf_ReadOnlySequence_GetPosition - { - private const int InnerCount = 10_000; - volatile static int _volatileInt = 0; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - int offset = (int)buffer.Length / 10; - SequencePosition end = buffer.GetPosition(0, buffer.End); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition pos = buffer.Start; - while (!pos.Equals(end)) - { - pos = buffer.GetPosition(offset, pos); - localInt ^= pos.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new byte[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - int offset = (int)buffer.Length / 10; - SequencePosition end = buffer.GetPosition(0, buffer.End); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition pos = buffer.Start; - while (!pos.Equals(end)) - { - pos = buffer.GetPosition(offset, pos); - localInt ^= pos.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount * 10)] - private static void Byte_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition pos = buffer.GetPosition(0); - localInt ^= pos.GetInteger(); - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount * 10)] - private static void Byte_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition pos = buffer.GetPosition(0); - localInt ^= pos.GetInteger(); - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new char[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - int offset = (int)buffer.Length / 10; - SequencePosition end = buffer.GetPosition(0, buffer.End); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition pos = buffer.Start; - while (!pos.Equals(end)) - { - pos = buffer.GetPosition(offset, pos); - localInt ^= pos.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void String(int bufSize, int bufOffset) - { - ReadOnlyMemory memory = new string('a', bufSize).AsMemory(); - memory = memory.Slice(bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(memory); - int offset = (int)buffer.Length / 10; - SequencePosition end = buffer.GetPosition(0, buffer.End); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition pos = buffer.Start; - while (!pos.Equals(end)) - { - pos = buffer.GetPosition(offset, pos); - localInt ^= pos.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount * 10)] - private static void Char_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.GetPosition(0); - localInt ^= p.GetInteger(); - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount * 10)] - private static void Char_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.GetPosition(0); - localInt ^= p.GetInteger(); - } - } - _volatileInt = localInt; - } - } - - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Slice.cs b/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Slice.cs deleted file mode 100644 index 41e7625ed7fe3..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.Slice.cs +++ /dev/null @@ -1,367 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Memory.Tests; -using System.MemoryTests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Tests -{ - public abstract class Perf_ReadOnlySequence_Slice_Byte: Perf_ReadOnlySequence_Slice - { - public Perf_ReadOnlySequence_Slice_Byte(ReadOnlySequenceFactory factory): base(factory) { } - - public class Array: Perf_ReadOnlySequence_Slice_Byte - { - public Array(): base(ReadOnlySequenceFactory.ArrayFactory) { } - } - - public class Memory : Perf_ReadOnlySequence_Slice_Byte - { - public Memory() : base(ReadOnlySequenceFactory.MemoryFactory) { } - } - - // 001 in name for correcter order in log - public class Segments001 : Perf_ReadOnlySequence_Slice_Byte - { - public Segments001() : base(ReadOnlySequenceFactory.SingleSegmentFactory) { } - } - - // 010 in name for correcter order in log - public class Segments010 : Perf_ReadOnlySequence_Slice_Byte - { - public Segments010() : base(new ReadOnlySequenceFactory.SegmentsTestSequenceFactory(10)) { } - } - - public class Segments100 : Perf_ReadOnlySequence_Slice_Byte - { - public Segments100() : base(new ReadOnlySequenceFactory.SegmentsTestSequenceFactory(100)) { } - } - } - - public abstract class Perf_ReadOnlySequence_Slice_Char: Perf_ReadOnlySequence_Slice - { - public Perf_ReadOnlySequence_Slice_Char(ReadOnlySequenceFactory factory): base(factory) { } - - public class Array: Perf_ReadOnlySequence_Slice_Char - { - public Array(): base(ReadOnlySequenceFactory.ArrayFactory) { } - } - - public class Memory : Perf_ReadOnlySequence_Slice_Char - { - public Memory() : base(ReadOnlySequenceFactory.MemoryFactory) { } - } - - public class String : Perf_ReadOnlySequence_Slice_Char - { - public String() : base(ReadOnlySequenceFactoryChar.StringFactory) { } - } - - // 001 in name for correcter order in log - public class Segments001 : Perf_ReadOnlySequence_Slice_Char - { - public Segments001() : base(ReadOnlySequenceFactory.SingleSegmentFactory) { } - } - - // 010 in name for correcter order in log - public class Segments010 : Perf_ReadOnlySequence_Slice_Char - { - public Segments010() : base(new ReadOnlySequenceFactory.SegmentsTestSequenceFactory(10)) { } - } - - public class Segments100 : Perf_ReadOnlySequence_Slice_Char - { - public Segments100() : base(new ReadOnlySequenceFactory.SegmentsTestSequenceFactory(100)) { } - } - } - - public abstract class Perf_ReadOnlySequence_Slice - { - private const int InnerCount = 10_000; - volatile static int _volatileInt = 0; - - internal ReadOnlySequenceFactory Factory { get; } - - public Perf_ReadOnlySequence_Slice(ReadOnlySequenceFactory factory) - { - Factory = factory; - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void Offset(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - long[] positions = PreparePositionsOffset(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - ReadOnlySequence sliced = buffer.Slice(positions[j]); - localInt ^= sliced.Start.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void OffsetLength(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - (long, long)[] positions = PreparePositionsOffsetLength(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - (long start, long length) startLength = positions[j]; - ReadOnlySequence sliced = buffer.Slice(startLength.start, startLength.length); - localInt ^= sliced.Start.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void OffsetEnd(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - (long, SequencePosition)[] positions = PreparePositionsOffsetEnd(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - (long start, SequencePosition end) startEnd = positions[j]; - ReadOnlySequence sliced = buffer.Slice(startEnd.start, startEnd.end); - localInt ^= sliced.Start.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void Start(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - SequencePosition[] positions = PreparePositionsStart(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - ReadOnlySequence sliced = buffer.Slice(positions[j]); - localInt ^= sliced.Start.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void StartLength(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - (SequencePosition, long)[] positions = PreparePositionsStartLength(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - (SequencePosition start, long length) startLength = positions[j]; - ReadOnlySequence sliced = buffer.Slice(startLength.start, startLength.length); - localInt ^= sliced.Start.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void StartEnd(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - (SequencePosition, SequencePosition)[] positions = PreparePositionsStartEnd(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - (SequencePosition start, SequencePosition end) startEnd = positions[j]; - ReadOnlySequence sliced = buffer.Slice(startEnd.start, startEnd.end); - localInt ^= sliced.Start.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 10)] - public void EmptyLoop(int bufSize, int posCount) - { - ReadOnlySequence buffer = Factory.CreateOfSize(bufSize); - - (SequencePosition, SequencePosition)[] positions = PreparePositionsStartEnd(buffer, posCount); - int indexLast = positions.Length - 1; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = indexLast; j >= 0; j--) - { - (SequencePosition start, SequencePosition end) startEnd = positions[j]; - localInt ^= startEnd.start.GetInteger(); - localInt ^= startEnd.end.GetInteger(); - } - } - } - _volatileInt = localInt; - } - } - - #region PreparePositions - - internal static long[] PreparePositionsOffset(in ReadOnlySequence buffer, int count) - { - var result = new long[count]; - - long length = buffer.Length; - for (int i = 0; i < count; i++) - result[i] = length * (i + 1) / (count + 1); - - return result; - } - - internal static SequencePosition[] PreparePositionsStart(in ReadOnlySequence buffer, int count) - { - long[] positions = PreparePositionsOffset(buffer, count); - - var result = new SequencePosition[positions.Length]; - for (int i = 0; i < positions.Length; i++) - result[i] = buffer.GetPosition(positions[i]); - - return result; - } - - internal static (long, long)[] PreparePositionsOffsetLength(in ReadOnlySequence buffer, int count) - { - var result = new (long offset, long length)[count]; - - long length = buffer.Length; - long endStart = length / 2; - long endLength = length - endStart; - for (int i = 0; i < count; i++) - { - result[i].offset = length * (i + 1) / (count + 1); - long endOffset = endLength * (i + 1) / count + endStart; - result[i].length = endOffset - result[i].offset; - } - - return result; - } - - internal static (long, SequencePosition)[] PreparePositionsOffsetEnd(in ReadOnlySequence buffer, int count) - { - (long offset, long length)[] positions = PreparePositionsOffsetLength(buffer, count); - - var result = new (long offset, SequencePosition end)[positions.Length]; - for (int i = 0; i < positions.Length; i++) - { - result[i].offset = positions[i].offset; - result[i].end = buffer.GetPosition(positions[i].offset + positions[i].length); - } - - return result; - } - - internal static (SequencePosition, long)[] PreparePositionsStartLength(in ReadOnlySequence buffer, int count) - { - (long offset, long length)[] positions = PreparePositionsOffsetLength(buffer, count); - - var result = new (SequencePosition start, long length)[positions.Length]; - for (int i = 0; i < positions.Length; i++) - { - result[i].start = buffer.GetPosition(positions[i].offset); - result[i].length = positions[i].length; - } - - return result; - } - - internal static (SequencePosition, SequencePosition)[] PreparePositionsStartEnd(in ReadOnlySequence buffer, int count) - { - (long offset, long length)[] positions = PreparePositionsOffsetLength(buffer, count); - - var result = new (SequencePosition start, SequencePosition end)[positions.Length]; - for (int i = 0; i < positions.Length; i++) - { - result[i].start = buffer.GetPosition(positions[i].offset); - result[i].end = buffer.GetPosition(positions[i].offset + positions[i].length); - } - - return result; - } - - #endregion - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.TryGet.cs b/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.TryGet.cs deleted file mode 100644 index 2d761181f958e..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.ReadOnlySequence.TryGet.cs +++ /dev/null @@ -1,314 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Memory.Tests; -using System.MemoryTests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Tests -{ - public class Perf_ReadOnlySequence_TryGet - { - private const int InnerCount = 100_000; - volatile static int _volatileInt = 0; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_Memory(int bufSize, int bufOffset) - { - var manager = new CustomMemoryForTest(new byte[bufSize], bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(manager.Memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Byte_SingleSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment1, bufSize - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount / 10)] - [InlineData(10_000, 100)] - private static void Byte_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new byte[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new byte[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Byte_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Byte_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_Array(int bufSize, int bufOffset) - { - var buffer = new ReadOnlySequence(new char[bufSize], bufOffset, bufSize - 2 * bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_Memory(int bufSize, int bufOffset) - { - var manager = new CustomMemoryForTest(new char[bufSize], bufOffset, bufSize - 2 * bufOffset); - var buffer = new ReadOnlySequence(manager.Memory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void Char_SingleSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment1, bufSize - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount / 10)] - [InlineData(10_000, 100)] - private static void Char_MultiSegment(int bufSize, int bufOffset) - { - var segment1 = new BufferSegment(new char[bufSize / 10]); - BufferSegment segment2 = segment1; - for (int j = 0; j < 10; j++) - segment2 = segment2.Append(new char[bufSize / 10]); - var buffer = new ReadOnlySequence(segment1, bufOffset, segment2, bufSize / 10 - bufOffset); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(10_000, 100)] - private static void String(int bufSize, int bufOffset) - { - ReadOnlyMemory strMemory = new string('a', bufSize).AsMemory(); - strMemory = strMemory.Slice(bufOffset, bufSize - bufOffset); - var buffer = new ReadOnlySequence(strMemory); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Char_Empty() - { - ReadOnlySequence buffer = ReadOnlySequence.Empty; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void Char_Default() - { - ReadOnlySequence buffer = default; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - int localInt = 0; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - SequencePosition p = buffer.Start; - while (buffer.TryGet(ref p, out ReadOnlyMemory memory)) - localInt ^= memory.Length; - } - } - _volatileInt = localInt; - } - } - - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.BinaryReadAndWrite.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.BinaryReadAndWrite.cs deleted file mode 100644 index 78f536b98ac2f..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.BinaryReadAndWrite.cs +++ /dev/null @@ -1,281 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; -using System.Net; -using System.Runtime.InteropServices; - -using static System.Buffers.Binary.BinaryPrimitives; - -namespace System.Buffers.Binary.Tests -{ - public class BinaryReadAndWriteTests - { - private const int InnerCount = 100000; - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ReadStructAndReverseBE() - { - Span spanBE = TestHelpers.GetSpanBE(); - - var readStruct = new TestHelpers.TestStructExplicit(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - readStruct = MemoryMarshal.Read(spanBE); - if (BitConverter.IsLittleEndian) - { - readStruct.S0 = ReverseEndianness(readStruct.S0); - readStruct.I0 = ReverseEndianness(readStruct.I0); - readStruct.L0 = ReverseEndianness(readStruct.L0); - readStruct.US0 = ReverseEndianness(readStruct.US0); - readStruct.UI0 = ReverseEndianness(readStruct.UI0); - readStruct.UL0 = ReverseEndianness(readStruct.UL0); - readStruct.S1 = ReverseEndianness(readStruct.S1); - readStruct.I1 = ReverseEndianness(readStruct.I1); - readStruct.L1 = ReverseEndianness(readStruct.L1); - readStruct.US1 = ReverseEndianness(readStruct.US1); - readStruct.UI1 = ReverseEndianness(readStruct.UI1); - readStruct.UL1 = ReverseEndianness(readStruct.UL1); - } - } - } - } - - Assert.Equal(TestHelpers.s_testExplicitStruct, readStruct); - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ReadStructAndReverseLE() - { - Span spanLE = TestHelpers.GetSpanLE(); - - var readStruct = new TestHelpers.TestStructExplicit(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - readStruct = MemoryMarshal.Read(spanLE); - if (!BitConverter.IsLittleEndian) - { - readStruct.S0 = ReverseEndianness(readStruct.S0); - readStruct.I0 = ReverseEndianness(readStruct.I0); - readStruct.L0 = ReverseEndianness(readStruct.L0); - readStruct.US0 = ReverseEndianness(readStruct.US0); - readStruct.UI0 = ReverseEndianness(readStruct.UI0); - readStruct.UL0 = ReverseEndianness(readStruct.UL0); - readStruct.S1 = ReverseEndianness(readStruct.S1); - readStruct.I1 = ReverseEndianness(readStruct.I1); - readStruct.L1 = ReverseEndianness(readStruct.L1); - readStruct.US1 = ReverseEndianness(readStruct.US1); - readStruct.UI1 = ReverseEndianness(readStruct.UI1); - readStruct.UL1 = ReverseEndianness(readStruct.UL1); - } - } - } - } - - Assert.Equal(TestHelpers.s_testExplicitStruct, readStruct); - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ReadStructFieldByFieldBE() - { - Span spanBE = TestHelpers.GetSpanBE(); - - var readStruct = new TestHelpers.TestStructExplicit(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - readStruct = new TestHelpers.TestStructExplicit - { - S0 = ReadInt16BigEndian(spanBE), - I0 = ReadInt32BigEndian(spanBE.Slice(2)), - L0 = ReadInt64BigEndian(spanBE.Slice(6)), - US0 = ReadUInt16BigEndian(spanBE.Slice(14)), - UI0 = ReadUInt32BigEndian(spanBE.Slice(16)), - UL0 = ReadUInt64BigEndian(spanBE.Slice(20)), - S1 = ReadInt16BigEndian(spanBE.Slice(28)), - I1 = ReadInt32BigEndian(spanBE.Slice(30)), - L1 = ReadInt64BigEndian(spanBE.Slice(34)), - US1 = ReadUInt16BigEndian(spanBE.Slice(42)), - UI1 = ReadUInt32BigEndian(spanBE.Slice(44)), - UL1 = ReadUInt64BigEndian(spanBE.Slice(48)) - }; - } - } - } - - Assert.Equal(TestHelpers.s_testExplicitStruct, readStruct); - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ReadStructFieldByFieldLE() - { - Span spanLE = TestHelpers.GetSpanLE(); - - var readStruct = new TestHelpers.TestStructExplicit(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - readStruct = new TestHelpers.TestStructExplicit - { - S0 = ReadInt16LittleEndian(spanLE), - I0 = ReadInt32LittleEndian(spanLE.Slice(2)), - L0 = ReadInt64LittleEndian(spanLE.Slice(6)), - US0 = ReadUInt16LittleEndian(spanLE.Slice(14)), - UI0 = ReadUInt32LittleEndian(spanLE.Slice(16)), - UL0 = ReadUInt64LittleEndian(spanLE.Slice(20)), - S1 = ReadInt16LittleEndian(spanLE.Slice(28)), - I1 = ReadInt32LittleEndian(spanLE.Slice(30)), - L1 = ReadInt64LittleEndian(spanLE.Slice(34)), - US1 = ReadUInt16LittleEndian(spanLE.Slice(42)), - UI1 = ReadUInt32LittleEndian(spanLE.Slice(44)), - UL1 = ReadUInt64LittleEndian(spanLE.Slice(48)) - }; - } - } - } - - Assert.Equal(TestHelpers.s_testExplicitStruct, readStruct); - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ReadStructFieldByFieldUsingBitConverterLE() - { - Span spanLE = TestHelpers.GetSpanLE(); - byte[] arrayLE = spanLE.ToArray(); - - var readStruct = new TestHelpers.TestStructExplicit(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - readStruct = new TestHelpers.TestStructExplicit - { - S0 = BitConverter.ToInt16(arrayLE, 0), - I0 = BitConverter.ToInt32(arrayLE, 2), - L0 = BitConverter.ToInt64(arrayLE, 6), - US0 = BitConverter.ToUInt16(arrayLE, 14), - UI0 = BitConverter.ToUInt32(arrayLE, 16), - UL0 = BitConverter.ToUInt64(arrayLE, 20), - S1 = BitConverter.ToInt16(arrayLE, 28), - I1 = BitConverter.ToInt32(arrayLE, 30), - L1 = BitConverter.ToInt64(arrayLE, 34), - US1 = BitConverter.ToUInt16(arrayLE, 42), - UI1 = BitConverter.ToUInt32(arrayLE, 44), - UL1 = BitConverter.ToUInt64(arrayLE, 48), - }; - } - } - } - - Assert.Equal(TestHelpers.s_testExplicitStruct, readStruct); - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ReadStructFieldByFieldUsingBitConverterBE() - { - Span spanBE = TestHelpers.GetSpanBE(); - byte[] arrayBE = spanBE.ToArray(); - - var readStruct = new TestHelpers.TestStructExplicit(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - readStruct = new TestHelpers.TestStructExplicit - { - S0 = BitConverter.ToInt16(arrayBE, 0), - I0 = BitConverter.ToInt32(arrayBE, 2), - L0 = BitConverter.ToInt64(arrayBE, 6), - US0 = BitConverter.ToUInt16(arrayBE, 14), - UI0 = BitConverter.ToUInt32(arrayBE, 16), - UL0 = BitConverter.ToUInt64(arrayBE, 20), - S1 = BitConverter.ToInt16(arrayBE, 28), - I1 = BitConverter.ToInt32(arrayBE, 30), - L1 = BitConverter.ToInt64(arrayBE, 34), - US1 = BitConverter.ToUInt16(arrayBE, 42), - UI1 = BitConverter.ToUInt32(arrayBE, 44), - UL1 = BitConverter.ToUInt64(arrayBE, 48), - }; - if (BitConverter.IsLittleEndian) - { - readStruct.S0 = ReverseEndianness(readStruct.S0); - readStruct.I0 = ReverseEndianness(readStruct.I0); - readStruct.L0 = ReverseEndianness(readStruct.L0); - readStruct.US0 = ReverseEndianness(readStruct.US0); - readStruct.UI0 = ReverseEndianness(readStruct.UI0); - readStruct.UL0 = ReverseEndianness(readStruct.UL0); - readStruct.S1 = ReverseEndianness(readStruct.S1); - readStruct.I1 = ReverseEndianness(readStruct.I1); - readStruct.L1 = ReverseEndianness(readStruct.L1); - readStruct.US1 = ReverseEndianness(readStruct.US1); - readStruct.UI1 = ReverseEndianness(readStruct.UI1); - readStruct.UL1 = ReverseEndianness(readStruct.UL1); - } - } - } - } - - Assert.Equal(TestHelpers.s_testExplicitStruct, readStruct); - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void MeasureReverseEndianness() - { - var myArray = new int[1000]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < myArray.Length; j++) - { - myArray[j] = ReverseEndianness(myArray[j]); - } - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void MeasureReverseUsingNtoH() - { - var myArray = new int[1000]; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (int j = 0; j < myArray.Length; j++) - { - myArray[j] = IPAddress.NetworkToHostOrder(myArray[j]); - } - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.BinarySearch.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.BinarySearch.cs deleted file mode 100644 index 621c306a66aa7..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.BinarySearch.cs +++ /dev/null @@ -1,286 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_BinarySearch - { - private const int InnerCount = 100000; - private const string NumberFormat = "D9"; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_Int_FirstIndex(int size) - { - BenchmarkAndAssertArray(size, 0, 0); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_Int_MiddleIndex(int size) - { - BenchmarkAndAssertArray(size, (size - 1) / 2, (size - 1) / 2); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_Int_LastIndex(int size) - { - BenchmarkAndAssertArray(size, size - 1, size - 1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_Int_NotFoundBefore(int size) - { - BenchmarkAndAssertArray(size, -1, -1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_Int_NotFoundAfter(int size) - { - BenchmarkAndAssertArray(size, size, ~size); - } - - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_String_FirstIndex(int size) - { - BenchmarkAndAssertArray(size, 0.ToString(NumberFormat), 0); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_String_MiddleIndex(int size) - { - BenchmarkAndAssertArray(size, ((size - 1) / 2).ToString(NumberFormat), (size - 1) / 2); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_String_LastIndex(int size) - { - BenchmarkAndAssertArray(size, (size - 1).ToString(NumberFormat), size - 1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_String_NotFoundBefore(int size) - { - // "/" is just before zero in character table - BenchmarkAndAssertArray(size, "/", -1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void ArrayBinarySearch_String_NotFoundAfter(int size) - { - BenchmarkAndAssertArray(size, (size).ToString(NumberFormat), ~size); - } - - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_Int_FirstIndex(int size) - { - BenchmarkAndAssertSpan(size, 0, 0); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_Int_MiddleIndex(int size) - { - BenchmarkAndAssertSpan(size, (size - 1) / 2, (size - 1) / 2); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_Int_LastIndex(int size) - { - BenchmarkAndAssertSpan(size, size - 1, size - 1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_Int_NotFoundBefore(int size) - { - BenchmarkAndAssertSpan(size, -1, -1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_Int_NotFoundAfter(int size) - { - BenchmarkAndAssertSpan(size, size, ~size); - } - - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_String_FirstIndex(int size) - { - BenchmarkAndAssertSpan(size, 0.ToString(NumberFormat), 0); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_String_MiddleIndex(int size) - { - BenchmarkAndAssertSpan(size, ((size - 1) / 2).ToString(NumberFormat), (size - 1) / 2); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_String_LastIndex(int size) - { - BenchmarkAndAssertSpan(size, (size - 1).ToString(NumberFormat), size - 1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_String_NotFoundBefore(int size) - { - // "/" is just before zero in character table - BenchmarkAndAssertSpan(size, "/", -1); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanBinarySearch_String_NotFoundAfter(int size) - { - BenchmarkAndAssertSpan(size, (size).ToString(NumberFormat), ~size); - } - - private static void BenchmarkAndAssertArray(int size, int value, int expectedIndex) - { - BenchmarkAndAssertArray(size, i => i, value, expectedIndex); - } - - private static void BenchmarkAndAssertArray(int size, string value, int expectedIndex) - { - BenchmarkAndAssertArray(size, i => i.ToString(NumberFormat), value, expectedIndex); - } - - private static void BenchmarkAndAssertArray(int size, Func toValue, T value, int expectedIndex) - where T : IComparable - { - var array = new T[size]; - for (int i = 0; i < array.Length; i++) - { - array[i] = toValue(i); - } - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= Array.BinarySearch(array, value); - } - } - } - Assert.Equal(expectedIndex, index); - } - - private static void BenchmarkAndAssertSpan(int size, int value, int expectedIndex) - { - BenchmarkAndAssertSpan(size, i => i, value, expectedIndex); - } - - private static void BenchmarkAndAssertSpan(int size, string value, int expectedIndex) - { - BenchmarkAndAssertSpan(size, i => i.ToString(NumberFormat), value, expectedIndex); - } - - private static void BenchmarkAndAssertSpan(int size, Func toValue, T value, int expectedIndex) - where T : IComparable - { - Span span = new T[size]; - for (int i = 0; i < span.Length; i++) - { - span[i] = toValue(i); - } - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= span.BinarySearch(value); - } - } - } - Assert.Equal(expectedIndex, index); - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs deleted file mode 100644 index 65179cd1f80bf..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_Clear - { - private const int NumIters = 10000; - - [Benchmark(InnerIterationCount = NumIters)] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(5)] - [InlineData(6)] - [InlineData(7)] - [InlineData(8)] - [InlineData(9)] - [InlineData(10)] - [InlineData(11)] - [InlineData(12)] - [InlineData(13)] - [InlineData(14)] - [InlineData(15)] - [InlineData(16)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void Int(int size) - { - var a = new int[size]; - var span = new Span(a); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - span.Clear(); - } - } - } - } - - [Benchmark(InnerIterationCount = NumIters)] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(5)] - [InlineData(6)] - [InlineData(7)] - [InlineData(8)] - [InlineData(9)] - [InlineData(10)] - [InlineData(11)] - [InlineData(12)] - [InlineData(13)] - [InlineData(14)] - [InlineData(15)] - [InlineData(16)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void References(int size) - { - var a = new object[size]; - var span = new Span(a); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - span.Clear(); - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.Contains.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.Contains.cs deleted file mode 100644 index 7c5a0b65a4c9f..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.Contains.cs +++ /dev/null @@ -1,317 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - // Adapted from Perf.Span.IndexOf.cs - public class Perf_Span_Contains - { - private const int InnerCount = 50_000; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(5)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(2000)] - public void SpanContainsChar(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - - bool found = true; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (!charSpan.Contains('5')) - found = false; - } - } - } - - Assert.True(found); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(5)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(2000)] - public void SpanIndexOfChar(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - - bool found = true; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (charSpan.IndexOf('5') < 0) - found = false; - } - } - } - - Assert.True(found); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(5)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(2000)] - public void SpanContainsCharAsBytes(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - - bool found = true; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (!charSpan.Contains('5')) // '5' = 53 - found = false; - } - } - } - - Assert.True(found); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(5)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(2000)] - public void StringContainsChar(int size) - { - string str = new string('0', size / 2) + "5"; - if (size > 1) - { - str += new string('0', size / 2 - 1); - } - - bool found = true; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (!str.Contains('5')) - found = false; - } - } - } - - Assert.True(found); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(2)] - [InlineData(5)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(2000)] - public void StringIndexOfChar(int size) - { - string str = new string('0', size / 2) + "5"; - if (size > 1) - { - str += new string('0', size / 2 - 1); - } - - bool found = true; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (str.IndexOf('5') < 0) - found = false; - } - } - } - - Assert.True(found); - } - - private static string GenerateInputString(char source, int count, char replaceChar, int replacePos) - { - char[] str = new char[count]; - for (int i = 0; i < count; i++) - { - str[i] = replaceChar; - } - str[replacePos] = replaceChar; - - return new string(str); - } - - public static IEnumerable s_indexTestData = new List - { - new object[] { "string1", '1' }, - new object[] { "foobardzsdzs", 'z' }, - new object[] { "StrIng", 'I' }, - new object[] { "\u3060", '\u305F' }, - new object[] { "ABCDE", 'c' }, - new object[] { "More Test's", '\'' }, - new object[] { "Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz", '~' }, - new object[] { "Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz", 'w' }, - new object[] { "Hello Worldbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbba!", 'y' }, - new object[] { GenerateInputString('A', 10, '5', 5), '5' }, - new object[] { GenerateInputString('A', 100, 'X', 70), 'x' }, - new object[] { GenerateInputString('A', 1000, 'G', 500), 'G' }, - new object[] { GenerateInputString('\u3060', 1000, 'x', 500), 'x' }, - new object[] { GenerateInputString('\u3060', 100, '\u3059', 50), '\u3059' } - }; - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(s_indexTestData))] - public ulong ContainsChar_StringAsSpan(string input, char value) - { - var count = 0UL; - - ReadOnlySpan inputSpan = input.AsSpan(); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (inputSpan.Contains(value)) - count++; - } - } - } - - return count; - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(s_indexTestData))] - public ulong ContainsChar_String(string input, char value) - { - var count = 0UL; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (input.Contains(value)) - count++; - } - } - } - - return count; - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(s_indexTestData))] - public ulong ContainsChar_StringLinq(string input, char value) - { - var count = 0UL; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (Linq.Enumerable.Contains(input, value)) - count++; - } - } - } - - return count; - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(s_indexTestData))] - public ulong ContainsChar_StringIndexOf(string input, char value) - { - var count = 0UL; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - if (input.IndexOf(value) >= 0) - count++; - } - } - } - - return count; - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(s_indexTestData))] - public ulong ContainsChar_Baseline(string input, char value) - { - var count = 0UL; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - for (var j = 0; j < input.Length; j++) - { - if (input[j] == value) - { - count++; - break; - } - } - } - } - } - - return count; - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.Fill.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.Fill.cs deleted file mode 100644 index 2344633e3b19f..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.Fill.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_Fill - { - [Benchmark] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(4)] - [InlineData(5)] - [InlineData(6)] - [InlineData(7)] - [InlineData(8)] - [InlineData(9)] - [InlineData(10)] - [InlineData(11)] - [InlineData(12)] - [InlineData(13)] - [InlineData(14)] - [InlineData(15)] - [InlineData(16)] - [InlineData(32)] - [InlineData(64)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - public void Int(int size) - { - var a = new int[size]; - var span = new Span(a); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - span.Fill(42); - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOf.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOf.cs deleted file mode 100644 index b80d4fb1da086..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOf.cs +++ /dev/null @@ -1,229 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_IndexOf - { - private const int InnerCount = 100000; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfChar(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= charSpan.IndexOf('5'); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfCharAsBytes(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.IndexOf(53); // '5' = 53 - } - } - } - Assert.Equal(size > 1 ? size : 0, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void StringIndexOfChar(int size) - { - string str = new string('0', size / 2) + "5"; - if (size > 1) - { - str += new string('0', size / 2 - 1); - } - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= str.IndexOf('5'); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanLastIndexOfChar(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= charSpan.LastIndexOf('5'); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanLastIndexOfCharAsBytes(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.LastIndexOf(53); // '5' = 53 - } - } - } - Assert.Equal(size > 1 ? size : 0, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void StringLastIndexOfChar(int size) - { - string str = new string('0', size / 2) + "5"; - if (size > 1) - { - str += new string('0', size / 2 - 1); - } - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= str.LastIndexOf('5'); - } - } - } - Assert.Equal(size / 2, index); - } - - private static string GenerateInputString(char source, int count, char replaceChar, int replacePos) - { - char[] str = new char[count]; - for (int i = 0; i < count; i++) - { - str[i] = replaceChar; - } - str[replacePos] = replaceChar; - - return new string(str); - } - - public static IEnumerable s_indexTestData = new List - { - new object[] { "string1", "string2", StringComparison.InvariantCulture }, - new object[] { "foobardzsdzs", "rddzs", StringComparison.InvariantCulture }, - new object[] { "StrIng", "string", StringComparison.OrdinalIgnoreCase }, - new object[] { "\u3060", "\u305F", StringComparison.InvariantCulture }, - new object[] { "ABCDE", "c", StringComparison.InvariantCultureIgnoreCase }, - new object[] { "More Test's", "Tests", StringComparison.OrdinalIgnoreCase }, - new object[] { "Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz", "~", StringComparison.Ordinal }, - new object[] { "Hello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello WorldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylongHello Worldbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbareallyreallylong!xyz", "w", StringComparison.OrdinalIgnoreCase }, - new object[] { "Hello Worldbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbba!", "y", StringComparison.Ordinal }, - new object[] { GenerateInputString('A', 10, '5', 5), "5", StringComparison.InvariantCulture }, - new object[] { GenerateInputString('A', 100, 'X', 70), "x", StringComparison.InvariantCultureIgnoreCase }, - new object[] { GenerateInputString('A', 100, 'D', 70), "d", StringComparison.OrdinalIgnoreCase }, - new object[] { GenerateInputString('A', 1000, 'G', 500), "G", StringComparison.Ordinal }, - new object[] { GenerateInputString('\u3060', 1000, 'x', 500), "x", StringComparison.Ordinal }, - new object[] { GenerateInputString('\u3060', 100, '\u3059', 50), "\u3059", StringComparison.Ordinal } - }; - - [Benchmark] - [MemberData(nameof(s_indexTestData))] - public void SpanIndexOfSpanComparison(string input, string value, StringComparison comparisonType) - { - ReadOnlySpan inputSpan = input.AsSpan(); - ReadOnlySpan valueSpan = value.AsSpan(); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - inputSpan.IndexOf(valueSpan, comparisonType); - } - } - -#if netcoreapp - [Benchmark] - [MemberData(nameof(s_indexTestData))] - public void SpanLastIndexOfSpanComparison(string input, string value, StringComparison comparisonType) - { - ReadOnlySpan inputSpan = input.AsSpan(); - ReadOnlySpan valueSpan = value.AsSpan(); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - inputSpan.LastIndexOf(valueSpan, comparisonType); - } - } -#endif - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOfAny.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOfAny.cs deleted file mode 100644 index f4a78276f580e..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.IndexOfAny.cs +++ /dev/null @@ -1,292 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_IndexOfAny - { - private const int InnerCount = 100000; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyChar_Two(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= charSpan.IndexOfAny('5', 'a'); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyCharAsBytes_Two(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.IndexOfAny(53, 54); // '5' = 53 - } - } - } - Assert.Equal(size > 1 ? size : 0, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyString_Two(int size) - { - string[] stringAray = new string[size]; - stringAray[size / 2] = "5"; - Span stringSpan = new Span(stringAray); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= stringSpan.IndexOfAny("5", "a"); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyChar_Three(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= charSpan.IndexOfAny('5', 'a', 'b'); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyCharAsBytes_Three(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.IndexOfAny(53, 54, 55); // '5' = 53 - } - } - } - Assert.Equal(size > 1 ? size : 0, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyString_Three(int size) - { - string[] stringAray = new string[size]; - stringAray[size / 2] = "5"; - Span stringSpan = new Span(stringAray); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= stringSpan.IndexOfAny("5", "a", "b"); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyChar_Many(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - ReadOnlySpan values = new ReadOnlySpan(new char[] { '5', 'a', 'b', 'c' }); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= charSpan.IndexOfAny(values); - } - } - } - Assert.Equal(size / 2, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyCharAsBytes_Many(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - ReadOnlySpan values = new ReadOnlySpan(new byte[] { 53, 54, 55, 56 }); // '5' = 53 - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.IndexOfAny(values); - } - } - } - Assert.Equal(size > 1 ? size : 0, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyCharAsBytes_NoSearchValue_Many(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - ReadOnlySpan values = new ReadOnlySpan(new byte[] { 54, 55, 56, 57 }); // '5' = 53 - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.IndexOfAny(values); - } - } - } - Assert.Equal(-1, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyCharAsBytes_ContainsLastSearchValue_Many(int size) - { - Span charSpan = new char[size]; - charSpan[size / 2] = '5'; - Span byteSpan = MemoryMarshal.AsBytes(charSpan); - ReadOnlySpan values = new ReadOnlySpan(new byte[] { 54, 55, 56, 53 }); // '5' = 53 - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= byteSpan.IndexOfAny(values); - } - } - } - Assert.Equal(size > 1 ? size : 0, index); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - public void SpanIndexOfAnyString_Many(int size) - { - string[] stringAray = new string[size]; - stringAray[size / 2] = "5"; - Span stringSpan = new Span(stringAray); - ReadOnlySpan values = new ReadOnlySpan(new string[] { "5", "a", "b", "c" }); - - int index = 0; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - index |= stringSpan.IndexOfAny(values); - } - } - } - Assert.Equal(size / 2, index); - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.SequenceCompareTo.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.SequenceCompareTo.cs deleted file mode 100644 index 7bc565c5b7baa..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.SequenceCompareTo.cs +++ /dev/null @@ -1,190 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_SequenceCompareTo - { - private const int InnerCount = 100000; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - public void SequenceCompareToSame_Byte(int size) - { - Span first = new byte[size]; - Span second = new byte[size]; - int result = -1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - result = first.SequenceCompareTo(second); - } - } - } - - Assert.Equal(0, result); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - public void SequenceCompareToDifferent_Byte(int size) - { - Span first = new byte[size]; - Span second = new byte[size]; - int result = -1; - - first[size/2] = 1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - result = first.SequenceCompareTo(second); - } - } - } - - Assert.Equal(1, result); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - public void SequenceCompareToSame_Int(int size) - { - Span first = new int[size]; - Span second = new int[size]; - int result = -1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - result = first.SequenceCompareTo(second); - } - } - } - - Assert.Equal(0, result); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - public void SequenceCompareToDifferent_Int(int size) - { - Span first = new int[size]; - Span second = new int[size]; - int result = -1; - - first[size/2] = 1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - result = first.SequenceCompareTo(second); - } - } - } - - Assert.Equal(1, result); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - public void SequenceCompareToSame_String(int size) - { - var firstStringArray = new string[size]; - var secondStringArray = new string[size]; - for (int i = 0; i < size; i++) - { - firstStringArray[i] = secondStringArray[i] = "0"; - } - - Span first = firstStringArray; - Span second = secondStringArray; - int result = -1; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - result = first.SequenceCompareTo(second); - } - } - } - - Assert.Equal(0, result); - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(1)] - [InlineData(10)] - [InlineData(100)] - [InlineData(1000)] - [InlineData(10000)] - public void SequenceCompareToDifferent_String(int size) - { - var firstStringArray = new string[size]; - var secondStringArray = new string[size]; - for (int i = 0; i < size; i++) - { - firstStringArray[i] = secondStringArray[i] = "0"; - } - - Span first = firstStringArray; - Span second = secondStringArray; - int result = -1; - - first[size/2] = "1"; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - result = first.SequenceCompareTo(second); - } - } - } - - Assert.Equal(1, result); - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.StartsWith.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.StartsWith.cs deleted file mode 100644 index 6d6b1946e63b1..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.StartsWith.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Memory.Tests -{ - public class Perf_Span_StartsWith - { - [Benchmark(InnerIterationCount = 10000)] - [InlineData(1, 1)] - [InlineData(10, 1)] - [InlineData(100, 1)] - [InlineData(1000, 1)] - [InlineData(10000, 1)] - [InlineData(10, 10)] - [InlineData(100, 10)] - [InlineData(1000, 10)] - [InlineData(10000, 10)] - [InlineData(100, 100)] - [InlineData(1000, 100)] - [InlineData(10000, 100)] - [InlineData(1000, 1000)] - [InlineData(10000, 1000)] - [InlineData(10000, 10000)] - public void Int(int size, int valSize) - { - var a = new int[size]; - for (int i = 0; i < size; i++) - { - int num = 65 + i % 26; - a[i] = num; - } - - var b = new int[valSize]; - for (int i = 0; i < valSize; i++) - { - int num = 65 + i % 26; - b[i] = num; - } - var span = new Span(a); - var value = new Span(b); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - bool result = span.StartsWith(value); - } - } - } - } - - [Benchmark(InnerIterationCount = 1000000)] - [InlineData(1, 1)] - [InlineData(10, 1)] - [InlineData(100, 1)] - [InlineData(1000, 1)] - [InlineData(10000, 1)] - [InlineData(10, 10)] - [InlineData(100, 10)] - [InlineData(1000, 10)] - [InlineData(10000, 10)] - [InlineData(100, 100)] - [InlineData(1000, 100)] - [InlineData(10000, 100)] - [InlineData(1000, 1000)] - [InlineData(10000, 1000)] - [InlineData(10000, 10000)] - public void Byte(int size, int valSize) - { - var a = new byte[size]; - for (int i = 0; i < size; i++) - { - int num = 65 + i % 26; - a[i] = (byte)num; - } - - var b = new byte[valSize]; - for (int i = 0; i < valSize; i++) - { - int num = 65 + i % 26; - b[i] = (byte)num; - } - var span = new Span(a); - var value = new Span(b); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - bool result = span.StartsWith(value); - } - } - } - } - - [Benchmark(InnerIterationCount = 10000)] - [InlineData(1, 1)] - [InlineData(10, 1)] - [InlineData(100, 1)] - [InlineData(1000, 1)] - [InlineData(10000, 1)] - [InlineData(10, 10)] - [InlineData(100, 10)] - [InlineData(1000, 10)] - [InlineData(10000, 10)] - [InlineData(100, 100)] - [InlineData(1000, 100)] - [InlineData(10000, 100)] - [InlineData(1000, 1000)] - [InlineData(10000, 1000)] - [InlineData(10000, 10000)] - public void String(int size, int valSize) - { - var a = new string[size]; - for (int i = 0; i < size; i++) - { - int num = 65 + i % 26; - a[i] = ((char)num).ToString(); - } - - var b = new string[valSize]; - for (int i = 0; i < valSize; i++) - { - int num = 65 + i % 26; - b[i] = ((char)num).ToString(); - } - var span = new Span(a); - var value = new Span(b); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - bool result = span.StartsWith(value); - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Utf8Formatter.cs b/src/libraries/System.Memory/tests/Performance/Perf.Utf8Formatter.cs deleted file mode 100644 index 2a3d9fa3c0052..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Utf8Formatter.cs +++ /dev/null @@ -1,267 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Text.Tests -{ - public static partial class Utf8FormatterTests - { - private const int InnerCount = 100000; - - // There are really only two integer formatters: Int64/UInt64. Benchmarking the others won't provide any extra code coverage. - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(214748364L)] - [InlineData(2L)] - [InlineData(21474836L)] - [InlineData(21474L)] - [InlineData(214L)] - [InlineData(2147L)] - [InlineData(214748L)] - [InlineData(21L)] - [InlineData(2147483L)] - [InlineData(922337203685477580L)] - [InlineData(92233720368547758L)] - [InlineData(9223372036854775L)] - [InlineData(922337203685477L)] - [InlineData(92233720368547L)] - [InlineData(9223372036854L)] - [InlineData(922337203685L)] - [InlineData(92233720368L)] - [InlineData(-214748364L)] - [InlineData(-2L)] - [InlineData(-21474836L)] - [InlineData(-21474L)] - [InlineData(-214L)] - [InlineData(-2147L)] - [InlineData(-214748L)] - [InlineData(-21L)] - [InlineData(-2147483L)] - [InlineData(-922337203685477580L)] - [InlineData(-92233720368547758L)] - [InlineData(-9223372036854775L)] - [InlineData(-922337203685477L)] - [InlineData(-92233720368547L)] - [InlineData(-9223372036854L)] - [InlineData(-922337203685L)] - [InlineData(-92233720368L)] - [InlineData(0L)] - [InlineData(-9223372036854775808L)] // min value - [InlineData(9223372036854775807L)] // max value - [InlineData(-2147483648L)] // int32 min value - [InlineData(2147483647L)] // int32 max value - [InlineData(-4294967295000000000L)] // -(uint.MaxValue * Billion) - [InlineData(4294967295000000000L)] // uint.MaxValue * Billion - [InlineData(-4294967295000000001L)] // -(uint.MaxValue * Billion + 1) - [InlineData(4294967295000000001L)] // uint.MaxValue * Billion + 1 - private static void FormatterInt64(long value) - { - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(-12837467)] // standard format - [InlineData(12837467)] // standard format - [InlineData(-1283)] // standard format short - [InlineData(1283)] // standard format short - [InlineData(0)] - [InlineData(-2147483648)] // int32 min value - [InlineData(2147483647)] // int32 max value - private static void FormatterInt32(int value) - { - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(214748364LU)] - [InlineData(2LU)] - [InlineData(21474836LU)] - [InlineData(21474LU)] - [InlineData(214LU)] - [InlineData(2147LU)] - [InlineData(214748LU)] - [InlineData(21LU)] - [InlineData(2147483LU)] - [InlineData(922337203685477580LU)] - [InlineData(92233720368547758LU)] - [InlineData(9223372036854775LU)] - [InlineData(922337203685477LU)] - [InlineData(92233720368547LU)] - [InlineData(9223372036854LU)] - [InlineData(922337203685LU)] - [InlineData(92233720368LU)] - [InlineData(0LU)] // min value - [InlineData(18446744073709551615LU)] // max value - [InlineData(2147483647LU)] // int32 max value - [InlineData(9223372036854775807LU)] // int64 max value - [InlineData(1000000000000000000LU)] // quintillion - [InlineData(4294967295000000000LU)] // uint.MaxValue * Billion - [InlineData(4294967295000000001LU)] // uint.MaxValue * Billion + 1 - private static void FormatterUInt64(ulong value) - { - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void FormatterDecimal() - { - decimal value = new decimal(1.23456789E+5); - - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - - // Reenable commented out test cases when https://github.com/xunit/xunit/issues/1822 is fixed. - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(double.NegativeInfinity)] // Negative Infinity - [InlineData(double.MinValue)] // Min Negative Normal - [InlineData(-3.14159265358979324)] // Negative pi - [InlineData(-2.71828182845904524)] // Negative e - [InlineData(-1.0)] // Negative One - // [InlineData(-2.2250738585072014E-308)] // Max Negative Normal - [InlineData(-2.2250738585072009E-308)] // Min Negative Subnormal - [InlineData(-double.Epsilon)] // Max Negative Subnormal (Negative Epsilon) - [InlineData(-0.0)] // Negative Zero - [InlineData(double.NaN)] // NaN - [InlineData(0.0)] // Positive Zero - [InlineData(double.Epsilon)] // Min Positive Subnormal (Positive Epsilon) - [InlineData(2.2250738585072009E-308)] // Max Positive Subnormal - // [InlineData(2.2250738585072014E-308)] // Min Positive Normal - [InlineData(1.0)] // Positive One - [InlineData(2.71828182845904524)] // Positive e - [InlineData(3.14159265358979324)] // Positive pi - [InlineData(double.MaxValue)] // Max Positive Normal - [InlineData(double.PositiveInfinity)] // Positive Infinity - private static void FormatterDouble(double value) - { - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - - // Reenable commented out test cases when https://github.com/xunit/xunit/issues/1822 is fixed. - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData(float.NegativeInfinity)] // Negative Infinity - [InlineData(float.MinValue)] // Min Negative Normal - [InlineData(-3.14159265f)] // Negative pi - [InlineData(-2.71828183f)] // Negative e - [InlineData(-1.0f)] // Negative One - // [InlineData(-1.17549435E-38f)] // Max Negative Normal - [InlineData(-1.17549421E-38f)] // Min Negative Subnormal - [InlineData(-float.Epsilon)] // Max Negative Subnormal (Negative Epsilon) - [InlineData(-0.0f)] // Negative Zero - [InlineData(float.NaN)] // NaN - [InlineData(0.0f)] // Positive Zero - [InlineData(float.Epsilon)] // Min Positive Subnormal (Positive Epsilon) - [InlineData(1.17549421E-38f)] // Max Positive Subnormal - // [InlineData(1.17549435E-38f)] // Min Positive Normal - [InlineData(1.0f)] // Positive One - [InlineData(2.71828183f)] // Positive e - [InlineData(3.14159265f)] // Positive pi - [InlineData(float.MaxValue)] // Max Positive Normal - [InlineData(float.PositiveInfinity)] // Positive Infinity - private static void FormatterSingle(float value) - { - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void FormatterDateTimeOffsetNow() - { - DateTimeOffset value = new DateTimeOffset(year: 2017, month: 12, day: 30, hour: 3, minute: 45, second: 22, millisecond: 950, offset: new TimeSpan(hours: -8, minutes: 0, seconds: 0)); - - byte[] utf8ByteArray = new byte[40]; - Span utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Formatter.TryFormat(value, utf8ByteSpan, out int bytesWritten); - TestHelpers.DoNotIgnore(value, bytesWritten); - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Utf8Parser.cs b/src/libraries/System.Memory/tests/Performance/Perf.Utf8Parser.cs deleted file mode 100644 index 882c4fb8781ac..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/Perf.Utf8Parser.cs +++ /dev/null @@ -1,919 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using System.Text; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Buffers.Text.Tests -{ - public static partial class Utf8ParserTests - { - private const int InnerCount = 100_000; - - private static readonly string[] s_UInt32TextArray = new string[10] - { - "42", - "429496", - "429496729", - "42949", - "4", - "42949672", - "4294", - "429", - "4294967295", - "4294967" - }; - - private static readonly string[] s_UInt32TextArrayHex = new string[8] - { - "A2", - "A29496", - "A2949", - "A", - "A2949672", - "A294", - "A29", - "A294967" - }; - - private static readonly string[] s_Int16TextArray = new string[13] - { - "21474", - "2", - "-21474", - "31484", - "-21", - "-2", - "214", - "2147", - "-2147", - "-9345", - "9345", - "1000", - "-214" - }; - - private static readonly string[] s_Int32TextArray = new string[20] - { - "214748364", - "2", - "21474836", - "-21474", - "21474", - "-21", - "-2", - "214", - "-21474836", - "-214748364", - "2147", - "-2147", - "-214748", - "-2147483", - "214748", - "-2147483648", - "2147483647", - "21", - "2147483", - "-214" - }; - - private static readonly string[] s_SByteTextArray = new string[17] - { - "95", - "2", - "112", - "-112", - "-21", - "-2", - "114", - "-114", - "-124", - "117", - "-117", - "-14", - "14", - "74", - "21", - "83", - "-127" - }; - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("2134567890")] // standard parse - [InlineData("18446744073709551615")] // max value - [InlineData("0")] // min value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - private static void StringToUInt64_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ulong.TryParse(text, out ulong value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("abcdef")] // standard parse - [InlineData("ffffffffffffffff")] // max value - [InlineData("0")] // min value - private static void StringToUInt64Hex_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ulong.TryParse(text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("2134567890")] // standard parse - [InlineData("18446744073709551615")] // max value - [InlineData("0")] // min value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - private static void ByteSpanToUInt64(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = new ReadOnlySpan(utf8ByteArray); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out ulong value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("abcdef")] // standard parse - [InlineData("ffffffffffffffff")] // max value - [InlineData("0")] // min value - private static void ByteSpanToUInt64Hex(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = new ReadOnlySpan(utf8ByteArray); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out ulong value, out int bytesConsumed, 'X'); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("2134567890")] // standard parse - [InlineData("4294967295")] // max value - [InlineData("0")] // min value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - private static void StringToUInt32_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - uint.TryParse(text, out uint value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void StringToUInt32_VariableLength_Baseline() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - uint.TryParse(s_UInt32TextArray[i % 10], out uint value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("abcdef")] // standard parse - [InlineData("ffffffff")] // max value - [InlineData("0")] // min value - private static void StringToUInt32Hex_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - uint.TryParse(text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void StringToUInt32Hex_VariableLength() - { - int textLength = s_UInt32TextArrayHex.Length; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - string text = s_UInt32TextArrayHex[i % textLength]; - uint.TryParse(text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("2134567890")] // standard parse - [InlineData("4294967295")] // max value - [InlineData("0")] // min value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - private static void ByteSpanToUInt32(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - var utf8ByteSpan = new ReadOnlySpan(utf8ByteArray); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out uint value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ByteSpanToUInt32_VariableLength() - { - int textLength = s_UInt32TextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_UInt32TextArray[i]); - } - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlySpan utf8ByteSpan = utf8ByteArray[i % textLength]; - Utf8Parser.TryParse(utf8ByteSpan, out uint value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("abcdef")] // standard parse - [InlineData("ffffffff")] // max value - [InlineData("0")] // min value - private static void ByteSpanToUInt32Hex(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - var utf8ByteSpan = new ReadOnlySpan(utf8ByteArray); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out uint value, out int bytesConsumed, 'X'); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ByteSpanToUInt32Hex_VariableLength() - { - int textLength = s_UInt32TextArrayHex.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_UInt32TextArrayHex[i]); - } - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlySpan utf8ByteSpan = utf8ByteArray[i % textLength]; - Utf8Parser.TryParse(utf8ByteSpan, out uint value, out int bytesConsumed, 'X'); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ByteSpanToSByte_VariableLength() - { - int textLength = s_SByteTextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_SByteTextArray[i]); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlySpan utf8ByteSpan = utf8ByteArray[i % textLength]; - Utf8Parser.TryParse(utf8ByteSpan, out sbyte value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("0")] - [InlineData("107")] // standard parse - [InlineData("127")] // max value - [InlineData("-128")] // min value - [InlineData("-21abcdefghijklmnop")] - [InlineData("21abcdefghijklmnop")] - [InlineData("00000000000000000000123")] - private static void StringToSByte_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - sbyte.TryParse(text, out sbyte value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void StringToSByte_VariableLength_Baseline() - { - int textLength = s_SByteTextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_SByteTextArray[i]); - } - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - sbyte.TryParse(s_SByteTextArray[i % textLength], out sbyte value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("0")] - [InlineData("107374182")] // standard parse - [InlineData("2147483647")] // max value - [InlineData("-2147483648")] // min value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - [InlineData("-21474abcdefghijklmnop")] - private static void ByteSpanToInt32(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - var utf8ByteSpan = new ReadOnlySpan(utf8ByteArray); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out int value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ByteSpanToInt32_VariableLength() - { - int textLength = s_Int32TextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_Int32TextArray[i]); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlySpan utf8ByteSpan = utf8ByteArray[i % textLength]; - Utf8Parser.TryParse(utf8ByteSpan, out int value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("0")] - [InlineData("107374182")] // standard parse - [InlineData("2147483647")] // max value - [InlineData("-2147483648")] // min value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - [InlineData("-21474abcdefghijklmnop")] - private static void StringToInt32_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - int.TryParse(text, out int value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void StringToInt32_VariableLength_Baseline() - { - int textLength = s_Int32TextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_Int32TextArray[i]); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - int.TryParse(s_Int32TextArray[i % textLength], out int value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ByteSpanToInt16_VariableLength() - { - int textLength = s_Int16TextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_Int16TextArray[i]); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - ReadOnlySpan utf8ByteSpan = utf8ByteArray[i % textLength]; - Utf8Parser.TryParse(utf8ByteSpan, out short value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("0")] - [InlineData("10737")] // standard parse - [InlineData("32767")] // max value - [InlineData("-32768")] // min value - [InlineData("000000000000000000001235abcdfg")] - private static void StringToInt16_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - short.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out short value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void StringToInt16_VariableLength_Baseline() - { - int textLength = s_Int16TextArray.Length; - byte[][] utf8ByteArray = (byte[][])Array.CreateInstance(typeof(byte[]), textLength); - for (var i = 0; i < textLength; i++) - { - utf8ByteArray[i] = Encoding.UTF8.GetBytes(s_Int16TextArray[i]); - } - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - short.TryParse(s_Int16TextArray[i % textLength], out short value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("True")] - [InlineData("False")] - private static void StringToBool_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - bool.TryParse(text, out bool value); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("True")] - [InlineData("False")] - private static void BytesSpanToBool(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out bool value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("0")] - [InlineData("107")] // standard parse - [InlineData("127")] // max value - [InlineData("-128")] // min value - [InlineData("-21abcdefghijklmnop")] - [InlineData("21abcdefghijklmnop")] - [InlineData("00000000000000000000123")] - private static void ByteSpanToSByte(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out sbyte value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("42")] // standard parse - [InlineData("0")] // min value - [InlineData("255")] // max value - private static void ByteSpanToByte(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out byte value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("42")] // standard parse - [InlineData("0")] // min value - [InlineData("255")] // max value - private static void StringToByte_Baseline(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - byte.TryParse(text, out byte value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("0")] - [InlineData("4212")] // standard parse - [InlineData("-32768")] // min value - [InlineData("32767")] // max value - [InlineData("000000000000000000001235abcdfg")] - private static void ByteSpanToInt16(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out short value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("4212")] // standard parse - [InlineData("0")] // min value - [InlineData("65535")] // max value - private static void ByteSpanToUInt16(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out ushort value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("12837467")] // standard parse - [InlineData("-9223372036854775808")] // min value - [InlineData("9223372036854775807")] // max value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - private static void ByteSpanToInt64(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out long value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("12837467")] // standard parse - [InlineData("-9223372036854775808")] // min value - [InlineData("9223372036854775807")] // max value - [InlineData("000000000000000000001235abcdfg")] - [InlineData("21474836abcdefghijklmnop")] - private static void StringToInt64_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - long.TryParse(text, out long value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("Fri, 30 Jun 2000 03:15:45 GMT")] // standard parse - private static void ByteSpanToTimeOffsetR(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out DateTimeOffset value, out int bytesConsumed, 'R'); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("Fri, 30 Jun 2000 03:15:45 GMT")] // standard parse - private static void StringToTimeOffsetR_Baseline(string text) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - DateTimeOffset.TryParseExact(text, "r", null, DateTimeStyles.None, out DateTimeOffset value); - TestHelpers.DoNotIgnore(value, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - private static void ByteSpanToDecimal() - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes("1.23456789E+5"); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out decimal value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - // Reenable commented out test cases when https://github.com/xunit/xunit/issues/1822 is fixed. - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("-Infinity")] // Negative Infinity - [InlineData("-1.7976931348623157E+308")] // Min Negative Normal - [InlineData("-3.1415926535897931")] // Negative pi - [InlineData("-2.7182818284590451")] // Negative e - [InlineData("-1")] // Negative One - // [InlineData("-2.2250738585072014E-308")] // Max Negative Normal - [InlineData("-2.2250738585072009E-308")] // Min Negative Subnormal - [InlineData("-4.94065645841247E-324")] // Max Negative Subnormal (Negative Epsilon) - [InlineData("-0.0")] // Negative Zero - [InlineData("NaN")] // NaN - [InlineData("0")] // Positive Zero - [InlineData("4.94065645841247E-324")] // Min Positive Subnormal (Positive Epsilon) - [InlineData("2.2250738585072009E-308")] // Max Positive Subnormal - // [InlineData("2.2250738585072014E-308")] // Min Positive Normal - [InlineData("1")] // Positive One - [InlineData("2.7182818284590451")] // Positive e - [InlineData("3.1415926535897931")] // Positive pi - [InlineData("1.7976931348623157E+308")] // Max Positive Normal - [InlineData("Infinity")] // Positive Infinity - private static void ByteSpanToDouble(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out double value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - - // Reenable commented out test cases when https://github.com/xunit/xunit/issues/1822 is fixed. - [Benchmark(InnerIterationCount = InnerCount)] - [InlineData("-Infinity")] // Negative Infinity - [InlineData("-3.40282347E+38")] // Min Negative Normal - [InlineData("-3.14159274")] // Negative pi - [InlineData("-2.71828175")] // Negative e - [InlineData("-1")] // Negative One - // [InlineData("-1.17549435E-38")] // Max Negative Normal - [InlineData("-1.17549421E-38")] // Min Negative Subnormal - [InlineData("-1.401298E-45")] // Max Negative Subnormal (Negative Epsilon) - [InlineData("-0.0")] // Negative Zero - [InlineData("NaN")] // NaN - [InlineData("0")] // Positive Zero - [InlineData("1.401298E-45")] // Min Positive Subnormal (Positive Epsilon) - [InlineData("1.17549421E-38")] // Max Positive Subnormal - // [InlineData("1.17549435E-38")] // Min Positive Normal - [InlineData("1")] // Positive One - [InlineData("2.71828175")] // Positive e - [InlineData("3.14159274")] // Positive pi - [InlineData("3.40282347E+38")] // Max Positive Normal - [InlineData("Infinity")] // Positive Infinity - private static void ByteSpanToSingle(string text) - { - byte[] utf8ByteArray = Encoding.UTF8.GetBytes(text); - ReadOnlySpan utf8ByteSpan = utf8ByteArray; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - Utf8Parser.TryParse(utf8ByteSpan, out float value, out int bytesConsumed); - TestHelpers.DoNotIgnore(value, bytesConsumed); - } - } - } - } - } -} diff --git a/src/libraries/System.Memory/tests/Performance/System.Memory.PerformanceTests.csproj b/src/libraries/System.Memory/tests/Performance/System.Memory.PerformanceTests.csproj deleted file mode 100644 index 7c84169891513..0000000000000 --- a/src/libraries/System.Memory/tests/Performance/System.Memory.PerformanceTests.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - true - {18482C55-6B57-41E8-BBC4-383B9E2C7AA2} - true - netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common\System\PerfUtils.cs - - - Common\System\MemoryTests\CustomMemoryForTest.cs - - - Common\System\Memory\Tests\BufferSegment.cs - - - Common\System\Memory\Tests\ReadOnlySequenceFactory.byte.cs - - - Common\System\Memory\Tests\ReadOnlySequenceFactory.char.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 7f1ccc4507782d6224ad6fcd3afd2edf042e444b Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:33:28 +0100 Subject: [PATCH 20/45] remove System.Net.Http.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/4dee2229eae448d0ba024340448d6acdf93c9d31 --- .../System.Net.Http/System.Net.Http.sln | 10 -- .../tests/Performance/Configurations.props | 7 -- .../Performance/Perf.SocketsHttpHandler.cs | 113 ------------------ .../System.Net.Http.PerformanceTests.csproj | 24 ---- 4 files changed, 154 deletions(-) delete mode 100644 src/libraries/System.Net.Http/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Net.Http/tests/Performance/Perf.SocketsHttpHandler.cs delete mode 100644 src/libraries/System.Net.Http/tests/Performance/System.Net.Http.PerformanceTests.csproj diff --git a/src/libraries/System.Net.Http/System.Net.Http.sln b/src/libraries/System.Net.Http/System.Net.Http.sln index d547403266fbe..de0dfb353f51f 100644 --- a/src/libraries/System.Net.Http/System.Net.Http.sln +++ b/src/libraries/System.Net.Http/System.Net.Http.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Http.Functional. {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} = {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Http.PerformanceTests", "tests\Performance\System.Net.Http.PerformanceTests.csproj", "{981FC867-9071-444D-9388-BC5826609F76}" - ProjectSection(ProjectDependencies) = postProject - {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} = {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Http.Unit.Tests", "tests\UnitTests\System.Net.Http.Unit.Tests.csproj", "{5F9C3C9F-652E-461E-B2D6-85D264F5A733}" ProjectSection(ProjectDependencies) = postProject {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} = {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} @@ -40,10 +35,6 @@ Global {C85CF035-7804-41FF-9557-48B7C948B58D}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {C85CF035-7804-41FF-9557-48B7C948B58D}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {C85CF035-7804-41FF-9557-48B7C948B58D}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {981FC867-9071-444D-9388-BC5826609F76}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {981FC867-9071-444D-9388-BC5826609F76}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {981FC867-9071-444D-9388-BC5826609F76}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {981FC867-9071-444D-9388-BC5826609F76}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {5F9C3C9F-652E-461E-B2D6-85D264F5A733}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {5F9C3C9F-652E-461E-B2D6-85D264F5A733}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {5F9C3C9F-652E-461E-B2D6-85D264F5A733}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -62,7 +53,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {C85CF035-7804-41FF-9557-48B7C948B58D} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {981FC867-9071-444D-9388-BC5826609F76} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {5F9C3C9F-652E-461E-B2D6-85D264F5A733} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {1D422B1D-D7C4-41B9-862D-EB3D98DF37DE} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {132BF813-FC40-4D39-8B6F-E55D7633F0ED} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} diff --git a/src/libraries/System.Net.Http/tests/Performance/Configurations.props b/src/libraries/System.Net.Http/tests/Performance/Configurations.props deleted file mode 100644 index 89d6ac0f025b9..0000000000000 --- a/src/libraries/System.Net.Http/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netcoreapp; - - - \ No newline at end of file diff --git a/src/libraries/System.Net.Http/tests/Performance/Perf.SocketsHttpHandler.cs b/src/libraries/System.Net.Http/tests/Performance/Perf.SocketsHttpHandler.cs deleted file mode 100644 index fe0f595246a9d..0000000000000 --- a/src/libraries/System.Net.Http/tests/Performance/Perf.SocketsHttpHandler.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Security; -using System.Net.Sockets; -using System.Security.Authentication; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Net.Http.Tests -{ - public sealed class SocketsHttpHandlerPerfTest - { - const int InnerIterationCount = 1000; - - public static IEnumerable Get_MemberData() => - from ssl in new[] { false, true } - from chunkedResponse in new[] { false, true } - from responseLength in new[] { 1, 100_000 } - select new object[] { ssl, chunkedResponse, responseLength }; - - [Benchmark(InnerIterationCount = InnerIterationCount)] - [MemberData(nameof(Get_MemberData))] - public async Task Get(bool ssl, bool chunkedResponse, int responseLength) - { - using (var serverCert = System.Net.Test.Common.Configuration.Certificates.GetServerCertificate()) - using (var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) - { - #region Server - listener.Bind(new IPEndPoint(IPAddress.Loopback, 0)); - listener.Listen(int.MaxValue); - string responseText = - "HTTP/1.1 200 OK\r\n" + (chunkedResponse ? - $"Transfer-Encoding: chunked\r\n\r\n{responseLength.ToString("X")}\r\n{new string('a', responseLength)}\r\n0\r\n\r\n" : - $"Content-Length: {responseLength}\r\n\r\n{new string('a', responseLength)}"); - ReadOnlyMemory responseBytes = Encoding.UTF8.GetBytes(responseText); - - Task serverTask = Task.Run(async () => - { - try - { - while (true) - { - using (Socket s = await listener.AcceptAsync()) - { - try - { - Stream stream = new NetworkStream(s); - if (ssl) - { - var sslStream = new SslStream(stream, false, delegate { return true; }); - await sslStream.AuthenticateAsServerAsync(serverCert, false, SslProtocols.None, false); - stream = sslStream; - } - - using (var reader = new StreamReader(stream, Encoding.ASCII, detectEncodingFromByteOrderMarks: false, bufferSize: 100)) - { - while (true) - { - while (!string.IsNullOrEmpty(await reader.ReadLineAsync())); - await stream.WriteAsync(responseBytes); - } - } - } - catch (SocketException e) when (e.SocketErrorCode == SocketError.ConnectionAborted) { } - } - } - } - catch { } - }); - #endregion - - var ep = (IPEndPoint)listener.LocalEndPoint; - var uri = new Uri($"http{(ssl?"s":"")}://{ep.Address}:{ep.Port}/"); - using (var handler = new SocketsHttpHandler()) - using (var invoker = new HttpMessageInvoker(handler)) - { - if (ssl) - { - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; - } - - var req = new HttpRequestMessage(HttpMethod.Get, uri); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerIterationCount; i++) - { - using (HttpResponseMessage resp = await invoker.SendAsync(req, CancellationToken.None)) - using (Stream respStream = await resp.Content.ReadAsStreamAsync()) - { - await respStream.CopyToAsync(Stream.Null); - } - } - } - } - } - - listener.Dispose(); - await serverTask; - } - } - } -} diff --git a/src/libraries/System.Net.Http/tests/Performance/System.Net.Http.PerformanceTests.csproj b/src/libraries/System.Net.Http/tests/Performance/System.Net.Http.PerformanceTests.csproj deleted file mode 100644 index 56002f7744bf1..0000000000000 --- a/src/libraries/System.Net.Http/tests/Performance/System.Net.Http.PerformanceTests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - {981FC867-9071-444D-9388-BC5826609F76} - netcoreapp-Debug;netcoreapp-Release - - - - - Common\System\PerfUtils.cs - - - Common\System\Net\Configuration.Certificates.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - - - - \ No newline at end of file From 5f562d592e7086a8aaeff210ab01c6817d99a305 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:35:52 +0100 Subject: [PATCH 21/45] remove System.Net.Primitives.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/877ab25ef474217307e490ea4bede8559a388195 --- .../System.Net.Primitives.sln | 10 -- .../PerformanceTests/Configurations.props | 10 -- .../PerformanceTests/CredentialCacheTests.cs | 97 ----------- .../IPAddressPerformanceTests.cs | 156 ------------------ ...tem.Net.Primitives.PerformanceTests.csproj | 16 -- 5 files changed, 289 deletions(-) delete mode 100644 src/libraries/System.Net.Primitives/tests/PerformanceTests/Configurations.props delete mode 100644 src/libraries/System.Net.Primitives/tests/PerformanceTests/CredentialCacheTests.cs delete mode 100644 src/libraries/System.Net.Primitives/tests/PerformanceTests/IPAddressPerformanceTests.cs delete mode 100644 src/libraries/System.Net.Primitives/tests/PerformanceTests/System.Net.Primitives.PerformanceTests.csproj diff --git a/src/libraries/System.Net.Primitives/System.Net.Primitives.sln b/src/libraries/System.Net.Primitives/System.Net.Primitives.sln index fbd317af3e610..9e8a4fe71f10b 100644 --- a/src/libraries/System.Net.Primitives/System.Net.Primitives.sln +++ b/src/libraries/System.Net.Primitives/System.Net.Primitives.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Primitives.Pal.T {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} = {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Primitives.PerformanceTests", "tests\PerformanceTests\System.Net.Primitives.PerformanceTests.csproj", "{86256B36-4C78-4A71-A80A-CCA35C4AE758}" - ProjectSection(ProjectDependencies) = postProject - {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} = {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Primitives.UnitTests.Tests", "tests\UnitTests\System.Net.Primitives.UnitTests.Tests.csproj", "{FCFF9C63-CE7A-476E-8241-7B7236FFDBFB}" ProjectSection(ProjectDependencies) = postProject {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} = {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} @@ -49,10 +44,6 @@ Global {7860A11A-1841-4416-8A30-28EEEB42C6BB}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {7860A11A-1841-4416-8A30-28EEEB42C6BB}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU {7860A11A-1841-4416-8A30-28EEEB42C6BB}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU - {86256B36-4C78-4A71-A80A-CCA35C4AE758}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU - {86256B36-4C78-4A71-A80A-CCA35C4AE758}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU - {86256B36-4C78-4A71-A80A-CCA35C4AE758}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU - {86256B36-4C78-4A71-A80A-CCA35C4AE758}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU {FCFF9C63-CE7A-476E-8241-7B7236FFDBFB}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {FCFF9C63-CE7A-476E-8241-7B7236FFDBFB}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {FCFF9C63-CE7A-476E-8241-7B7236FFDBFB}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -72,7 +63,6 @@ Global GlobalSection(NestedProjects) = preSolution {E671BC9F-A64C-4504-8B00-7A3215B99AF9} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {7860A11A-1841-4416-8A30-28EEEB42C6BB} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {86256B36-4C78-4A71-A80A-CCA35C4AE758} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {FCFF9C63-CE7A-476E-8241-7B7236FFDBFB} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {8772BC91-7B55-49B9-94FA-4B1BE5BEAB55} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {D7A4CF9D-78AA-4140-83E3-6BC43EF2DBB8} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} diff --git a/src/libraries/System.Net.Primitives/tests/PerformanceTests/Configurations.props b/src/libraries/System.Net.Primitives/tests/PerformanceTests/Configurations.props deleted file mode 100644 index b18c784fc4095..0000000000000 --- a/src/libraries/System.Net.Primitives/tests/PerformanceTests/Configurations.props +++ /dev/null @@ -1,10 +0,0 @@ - - - - netstandard-Unix; - netstandard-Windows_NT; - netcoreapp-Unix; - netcoreapp-Windows_NT; - - - diff --git a/src/libraries/System.Net.Primitives/tests/PerformanceTests/CredentialCacheTests.cs b/src/libraries/System.Net.Primitives/tests/PerformanceTests/CredentialCacheTests.cs deleted file mode 100644 index 11fa58df92a01..0000000000000 --- a/src/libraries/System.Net.Primitives/tests/PerformanceTests/CredentialCacheTests.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Net.Primitives.Tests -{ - public static class CredentialCacheTests - { - private const string UriPrefix = "http://name"; - private const string HostPrefix = "name"; - private const int Port = 80; - private const string AuthenticationType = "authType"; - - private static readonly NetworkCredential s_credential = new NetworkCredential(); - - [Benchmark] - [MeasureGCCounts] - [InlineData("http://notfound", 0)] - [InlineData("http://notfound", 10)] - [InlineData("http://name5", 10)] - public static void GetCredential_Uri(string uriString, int uriCount) - { - var uri = new Uri(uriString); - CredentialCache cc = CreateCredentialCache(uriCount, hostPortCount: 0); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - cc.GetCredential(uri, AuthenticationType); - } - } - } - - [Benchmark] - [MeasureGCCounts] - [InlineData("notfound", 0)] - [InlineData("notfound", 10)] - [InlineData("name5", 10)] - public static void GetCredential_HostPort(string host, int hostPortCount) - { - CredentialCache cc = CreateCredentialCache(uriCount: 0, hostPortCount: 0); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - cc.GetCredential(host, Port, AuthenticationType); - } - } - } - - [Benchmark] - [MeasureGCCounts] - [InlineData(0, 0)] - [InlineData(10, 0)] - [InlineData(0, 10)] - [InlineData(10, 10)] - public static void ForEach(int uriCount, int hostPortCount) - { - CredentialCache cc = CreateCredentialCache(uriCount, hostPortCount); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - foreach (var c in cc) - { - // just iterate - } - } - } - } - - private static CredentialCache CreateCredentialCache(int uriCount, int hostPortCount) - { - var cc = new CredentialCache(); - - for (int i = 0; i < uriCount; i++) - { - Uri uri = new Uri(UriPrefix + i.ToString()); - cc.Add(uri, AuthenticationType, s_credential); - } - - for (int i = 0; i < hostPortCount; i++) - { - string host = HostPrefix + i.ToString(); - cc.Add(host, Port, AuthenticationType, s_credential); - } - - return cc; - } - } -} diff --git a/src/libraries/System.Net.Primitives/tests/PerformanceTests/IPAddressPerformanceTests.cs b/src/libraries/System.Net.Primitives/tests/PerformanceTests/IPAddressPerformanceTests.cs deleted file mode 100644 index babc47ab09466..0000000000000 --- a/src/libraries/System.Net.Primitives/tests/PerformanceTests/IPAddressPerformanceTests.cs +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Net.Primitives.Tests -{ - public static class IPAddressPerformanceTests - { - public static readonly object[][] TestAddresses = - { - new object[] { new byte[] { 0x8f, 0x18, 0x14, 0x24 } }, - new object[] { new byte[] { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 } }, - }; - - [Benchmark] - [MeasureGCCounts] - [MemberData(nameof(TestAddresses))] - public static void TryWriteBytes(byte[] address) - { - var ip = new IPAddress(address); - var bytes = new byte[address.Length]; - var bytesSpan = new Span(bytes); - int bytesWritten = 0; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; ++i) - { - ip.TryWriteBytes(bytesSpan, out bytesWritten); ip.TryWriteBytes(bytesSpan, out bytesWritten); - ip.TryWriteBytes(bytesSpan, out bytesWritten); ip.TryWriteBytes(bytesSpan, out bytesWritten); - ip.TryWriteBytes(bytesSpan, out bytesWritten); ip.TryWriteBytes(bytesSpan, out bytesWritten); - ip.TryWriteBytes(bytesSpan, out bytesWritten); ip.TryWriteBytes(bytesSpan, out bytesWritten); - } - } - } - } - - [Benchmark] - [MeasureGCCounts] - [MemberData(nameof(TestAddresses))] - public static void GetAddressBytes(byte[] address) - { - var ip = new IPAddress(address); - byte[] bytes; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; ++i) - { - bytes = ip.GetAddressBytes(); bytes = ip.GetAddressBytes(); - bytes = ip.GetAddressBytes(); bytes = ip.GetAddressBytes(); - bytes = ip.GetAddressBytes(); bytes = ip.GetAddressBytes(); - } - } - } - } - - [Benchmark] - [MeasureGCCounts] - [MemberData(nameof(TestAddresses))] - public static void Ctor_Bytes(byte[] address) - { - IPAddress ip; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; ++i) - { - ip = new IPAddress(address); ip = new IPAddress(address); - ip = new IPAddress(address); ip = new IPAddress(address); - ip = new IPAddress(address); ip = new IPAddress(address); - ip = new IPAddress(address); ip = new IPAddress(address); - } - } - } - } - - [Benchmark] - [MeasureGCCounts] - [MemberData(nameof(TestAddresses))] - public static void Ctor_Span(byte[] address) - { - var span = new ReadOnlySpan(address); - IPAddress ip; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; ++i) - { - ip = new IPAddress(span); ip = new IPAddress(span); - ip = new IPAddress(span); ip = new IPAddress(span); - ip = new IPAddress(span); ip = new IPAddress(span); - ip = new IPAddress(span); ip = new IPAddress(span); - } - } - } - } - - [Benchmark] - [MeasureGCCounts] - [MemberData(nameof(TestAddresses))] - public static void TryFormat(byte[] address) - { - const int INET6_ADDRSTRLEN = 65; - var buffer = new char[INET6_ADDRSTRLEN]; - var result = new Span(buffer); - int charsWritten; - - var ip = new IPAddress(address); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; ++i) - { - ip.TryFormat(result, out charsWritten); - } - } - } - } - - [Benchmark] - [MeasureGCCounts] - [MemberData(nameof(TestAddresses))] - public static void ToString(byte[] address) - { - var ip = new IPAddress(address); - - string result; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; ++i) - { - result = ip.ToString(); result = ip.ToString(); - result = ip.ToString(); result = ip.ToString(); - result = ip.ToString(); result = ip.ToString(); - result = ip.ToString(); result = ip.ToString(); - result = ip.ToString(); result = ip.ToString(); - result = ip.ToString(); result = ip.ToString(); - } - } - } - } - } -} diff --git a/src/libraries/System.Net.Primitives/tests/PerformanceTests/System.Net.Primitives.PerformanceTests.csproj b/src/libraries/System.Net.Primitives/tests/PerformanceTests/System.Net.Primitives.PerformanceTests.csproj deleted file mode 100644 index 5aa26fe44779c..0000000000000 --- a/src/libraries/System.Net.Primitives/tests/PerformanceTests/System.Net.Primitives.PerformanceTests.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - {86256B36-4C78-4A71-A80A-CCA35C4AE758} - netcoreapp-Unix-Debug;netcoreapp-Unix-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netstandard-Unix-Debug;netstandard-Unix-Release;netstandard-Windows_NT-Debug;netstandard-Windows_NT-Release - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 45fa8734a2953ab9467b6ec006d1fac83065b3a9 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:39:31 +0100 Subject: [PATCH 22/45] remove System.Net.Sockets.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/c04eac176b9c207b2e23463436be2585767d7071 --- .../System.Net.Sockets/System.Net.Sockets.sln | 10 - .../tests/Performance/Configurations.props | 8 - .../Performance/Perf.Socket.SendReceive.cs | 197 ------------------ ...System.Net.Sockets.PerformanceTests.csproj | 18 -- 4 files changed, 233 deletions(-) delete mode 100644 src/libraries/System.Net.Sockets/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Net.Sockets/tests/Performance/Perf.Socket.SendReceive.cs delete mode 100644 src/libraries/System.Net.Sockets/tests/Performance/System.Net.Sockets.PerformanceTests.csproj diff --git a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln index 84fb478252254..8a3657e31f293 100644 --- a/src/libraries/System.Net.Sockets/System.Net.Sockets.sln +++ b/src/libraries/System.Net.Sockets/System.Net.Sockets.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Sockets.Async.Pe {43311AFB-D7C4-4E5A-B1DE-855407F90D1B} = {43311AFB-D7C4-4E5A-B1DE-855407F90D1B} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Sockets.PerformanceTests", "tests\Performance\System.Net.Sockets.PerformanceTests.csproj", "{02092D8A-E8C4-414A-B6FB-470BD1EC9242}" - ProjectSection(ProjectDependencies) = postProject - {43311AFB-D7C4-4E5A-B1DE-855407F90D1B} = {43311AFB-D7C4-4E5A-B1DE-855407F90D1B} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Sockets", "src\System.Net.Sockets.csproj", "{43311AFB-D7C4-4E5A-B1DE-855407F90D1B}" ProjectSection(ProjectDependencies) = postProject {834E3534-6A11-4A8D-923F-35C1E71CCEC3} = {834E3534-6A11-4A8D-923F-35C1E71CCEC3} @@ -44,10 +39,6 @@ Global {BB5C85AD-C51A-4903-80E9-6F6E1AC1AD34}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU {BB5C85AD-C51A-4903-80E9-6F6E1AC1AD34}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU {BB5C85AD-C51A-4903-80E9-6F6E1AC1AD34}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU - {02092D8A-E8C4-414A-B6FB-470BD1EC9242}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {02092D8A-E8C4-414A-B6FB-470BD1EC9242}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {02092D8A-E8C4-414A-B6FB-470BD1EC9242}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {02092D8A-E8C4-414A-B6FB-470BD1EC9242}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {43311AFB-D7C4-4E5A-B1DE-855407F90D1B}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {43311AFB-D7C4-4E5A-B1DE-855407F90D1B}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {43311AFB-D7C4-4E5A-B1DE-855407F90D1B}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -63,7 +54,6 @@ Global GlobalSection(NestedProjects) = preSolution {8CBA022C-635F-4C8D-9D29-CD8AAC68C8E6} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {BB5C85AD-C51A-4903-80E9-6F6E1AC1AD34} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {02092D8A-E8C4-414A-B6FB-470BD1EC9242} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {43311AFB-D7C4-4E5A-B1DE-855407F90D1B} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {834E3534-6A11-4A8D-923F-35C1E71CCEC3} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Net.Sockets/tests/Performance/Configurations.props b/src/libraries/System.Net.Sockets/tests/Performance/Configurations.props deleted file mode 100644 index f5d3d45ffbf44..0000000000000 --- a/src/libraries/System.Net.Sockets/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp; - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Net.Sockets/tests/Performance/Perf.Socket.SendReceive.cs b/src/libraries/System.Net.Sockets/tests/Performance/Perf.Socket.SendReceive.cs deleted file mode 100644 index c9a119ab284e2..0000000000000 --- a/src/libraries/System.Net.Sockets/tests/Performance/Perf.Socket.SendReceive.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Net.Sockets.Tests -{ - public class SocketSendReceivePerfTest - { -#if netcoreapp - [Benchmark(InnerIterationCount = 10_000), MeasureGCAllocations] - public async Task SendAsyncThenReceiveAsync_Task() - { - await OpenLoopbackConnectionAsync(async (client, server) => - { - ReadOnlyMemory clientBuffer = new byte[1]; - Memory serverBuffer = new byte[1]; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - await client.SendAsync(clientBuffer, SocketFlags.None); - await server.ReceiveAsync(serverBuffer, SocketFlags.None); - } - } - } - }); - } - - [Benchmark(InnerIterationCount = 10_000), MeasureGCAllocations] - public async Task ReceiveAsyncThenSendAsync_Task() - { - await OpenLoopbackConnectionAsync(async (client, server) => - { - ReadOnlyMemory clientBuffer = new byte[1]; - Memory serverBuffer = new byte[1]; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - ValueTask r = server.ReceiveAsync(serverBuffer, SocketFlags.None); - await client.SendAsync(clientBuffer, SocketFlags.None); - await r; - } - } - } - }); - } -#endif - - [Benchmark(InnerIterationCount = 10_000), MeasureGCAllocations] - public async Task SendAsyncThenReceiveAsync_SocketAsyncEventArgs() - { - await OpenLoopbackConnectionAsync(async (client, server) => - { - var clientSaea = new AwaitableSocketAsyncEventArgs(); - var serverSaea = new AwaitableSocketAsyncEventArgs(); - - clientSaea.SetBuffer(new byte[1], 0, 1); - serverSaea.SetBuffer(new byte[1], 0, 1); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - if (client.SendAsync(clientSaea)) - { - await clientSaea; - } - if (server.ReceiveAsync(serverSaea)) - { - await serverSaea; - } - } - } - } - }); - } - - [Benchmark(InnerIterationCount = 10_000), MeasureGCAllocations] - public async Task ReceiveAsyncThenSendAsync_SocketAsyncEventArgs() - { - await OpenLoopbackConnectionAsync(async (client, server) => - { - var clientSaea = new AwaitableSocketAsyncEventArgs(); - var serverSaea = new AwaitableSocketAsyncEventArgs(); - - clientSaea.SetBuffer(new byte[1], 0, 1); - serverSaea.SetBuffer(new byte[1], 0, 1); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - bool pendingServer = server.ReceiveAsync(serverSaea); - - if (client.SendAsync(clientSaea)) - { - await clientSaea; - } - - if (pendingServer) - { - await serverSaea; - } - } - } - } - }); - } - - private static async Task OpenLoopbackConnectionAsync(Func func) - { - using (var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) - using (var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) - { - listener.Bind(new IPEndPoint(IPAddress.Loopback, 0)); - listener.Listen(1); - - Task acceptTask = listener.AcceptAsync(); - Task connectTask = client.ConnectAsync(listener.LocalEndPoint); - - await await Task.WhenAny(acceptTask, connectTask); - await Task.WhenAll(acceptTask, connectTask); - - using (Socket server = await acceptTask) - { - await func(client, server); - } - } - } - - internal sealed class AwaitableSocketAsyncEventArgs : SocketAsyncEventArgs, ICriticalNotifyCompletion - { - private static readonly Action s_completedSentinel = () => { }; - private Action _continuation; - - public AwaitableSocketAsyncEventArgs() - { - Completed += delegate - { - Action c = _continuation; - if (c != null) - { - c(); - } - else - { - Interlocked.CompareExchange(ref _continuation, s_completedSentinel, null)?.Invoke(); - } - }; - } - - public AwaitableSocketAsyncEventArgs GetAwaiter() => this; - - public bool IsCompleted => _continuation != null; - - public void UnsafeOnCompleted(Action continuation) => OnCompleted(continuation); - - public void OnCompleted(Action continuation) - { - if (ReferenceEquals(_continuation, s_completedSentinel) || - ReferenceEquals(Interlocked.CompareExchange(ref _continuation, continuation, null), s_completedSentinel)) - { - Task.Run(continuation); - } - } - - public int GetResult() - { - _continuation = null; - if (SocketError != SocketError.Success) - { - throw new SocketException((int)SocketError); - } - return BytesTransferred; - } - } - } -} diff --git a/src/libraries/System.Net.Sockets/tests/Performance/System.Net.Sockets.PerformanceTests.csproj b/src/libraries/System.Net.Sockets/tests/Performance/System.Net.Sockets.PerformanceTests.csproj deleted file mode 100644 index 3ff05c2b7b54f..0000000000000 --- a/src/libraries/System.Net.Sockets/tests/Performance/System.Net.Sockets.PerformanceTests.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - {02092D8A-E8C4-414A-B6FB-470BD1EC9242} - netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From f623fd785282eb4c3f69a6b142b50a09777f3e00 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:41:28 +0100 Subject: [PATCH 23/45] remove System.Numerics.Vectors.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/b9b89238442f7ce52163a04f15165fd0ac264577 --- .../System.Numerics.Vectors.sln | 10 - .../tests/Performance/Configurations.props | 8 - .../GenericVectorConstructorTests.cs | 353 ------------------ .../GenericVectorConstructorTests.tt | 119 ------ ...m.Numerics.Vectors.PerformanceTests.csproj | 81 ---- .../tests/Performance/Vector2/AddFunction.cs | 41 -- .../tests/Performance/Vector2/AddOperator.cs | 41 -- .../tests/Performance/Vector2/Distance.cs | 76 ---- .../Performance/Vector2/DistanceSquared.cs | 76 ---- .../tests/Performance/Vector2/Dot.cs | 76 ---- .../tests/Performance/Vector2/GetHashCode.cs | 76 ---- .../tests/Performance/Vector2/Length.cs | 76 ---- .../Performance/Vector2/LengthSquared.cs | 76 ---- .../Performance/Vector2/MultiplyFunction.cs | 41 -- .../Performance/Vector2/MultiplyOperator.cs | 41 -- .../tests/Performance/Vector2/Normalize.cs | 74 ---- .../tests/Performance/Vector2/SquareRoot.cs | 74 ---- .../Performance/Vector2/SubtractFunction.cs | 41 -- .../Performance/Vector2/SubtractOperator.cs | 41 -- .../tests/Performance/Vector3/AddFunction.cs | 41 -- .../tests/Performance/Vector3/AddOperator.cs | 41 -- .../tests/Performance/Vector3/Cross.cs | 41 -- .../tests/Performance/Vector3/Distance.cs | 76 ---- .../Performance/Vector3/DistanceSquared.cs | 76 ---- .../tests/Performance/Vector3/Dot.cs | 76 ---- .../tests/Performance/Vector3/GetHashCode.cs | 76 ---- .../tests/Performance/Vector3/Length.cs | 76 ---- .../Performance/Vector3/LengthSquared.cs | 76 ---- .../Performance/Vector3/MultiplyFunction.cs | 41 -- .../Performance/Vector3/MultiplyOperator.cs | 41 -- .../tests/Performance/Vector3/Normalize.cs | 74 ---- .../tests/Performance/Vector3/SquareRoot.cs | 74 ---- .../Performance/Vector3/SubtractFunction.cs | 41 -- .../Performance/Vector3/SubtractOperator.cs | 41 -- .../tests/Performance/Vector4/AddFunction.cs | 41 -- .../tests/Performance/Vector4/AddOperator.cs | 41 -- .../tests/Performance/Vector4/Distance.cs | 76 ---- .../Performance/Vector4/DistanceSquared.cs | 76 ---- .../tests/Performance/Vector4/Dot.cs | 76 ---- .../tests/Performance/Vector4/GetHashCode.cs | 76 ---- .../tests/Performance/Vector4/Length.cs | 76 ---- .../Performance/Vector4/LengthSquared.cs | 76 ---- .../Performance/Vector4/MultiplyFunction.cs | 41 -- .../Performance/Vector4/MultiplyOperator.cs | 41 -- .../tests/Performance/Vector4/Normalize.cs | 74 ---- .../tests/Performance/Vector4/SquareRoot.cs | 74 ---- .../Performance/Vector4/SubtractFunction.cs | 41 -- .../Performance/Vector4/SubtractOperator.cs | 41 -- .../tests/Performance/VectorTests.cs | 116 ------ 49 files changed, 3278 deletions(-) delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.tt delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/System.Numerics.Vectors.PerformanceTests.csproj delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Distance.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/DistanceSquared.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Dot.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/GetHashCode.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Length.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/LengthSquared.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Normalize.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SquareRoot.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Cross.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Distance.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/DistanceSquared.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Dot.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/GetHashCode.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Length.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/LengthSquared.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Normalize.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SquareRoot.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Distance.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/DistanceSquared.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Dot.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/GetHashCode.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Length.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/LengthSquared.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Normalize.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SquareRoot.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractFunction.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractOperator.cs delete mode 100644 src/libraries/System.Numerics.Vectors/tests/Performance/VectorTests.cs diff --git a/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln b/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln index 98843f0d862d3..364023c90e572 100644 --- a/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln +++ b/src/libraries/System.Numerics.Vectors/System.Numerics.Vectors.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Numerics.Vectors.Tes {53134B0C-0D57-481B-B84E-D1991E8D54FF} = {53134B0C-0D57-481B-B84E-D1991E8D54FF} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Numerics.Vectors.PerformanceTests", "tests\Performance\System.Numerics.Vectors.PerformanceTests.csproj", "{D9906F1A-A41A-43CD-81D2-BA94CF0001C9}" - ProjectSection(ProjectDependencies) = postProject - {53134B0C-0D57-481B-B84E-D1991E8D54FF} = {53134B0C-0D57-481B-B84E-D1991E8D54FF} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Numerics.Vectors", "src\System.Numerics.Vectors.csproj", "{53134B0C-0D57-481B-B84E-D1991E8D54FF}" ProjectSection(ProjectDependencies) = postProject {650277B5-9423-4ACE-BB54-2659995B21C7} = {650277B5-9423-4ACE-BB54-2659995B21C7} @@ -35,10 +30,6 @@ Global {99E1E564-0EF4-4E33-BECE-8ABE64771349}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {99E1E564-0EF4-4E33-BECE-8ABE64771349}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {99E1E564-0EF4-4E33-BECE-8ABE64771349}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {D9906F1A-A41A-43CD-81D2-BA94CF0001C9}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {D9906F1A-A41A-43CD-81D2-BA94CF0001C9}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {D9906F1A-A41A-43CD-81D2-BA94CF0001C9}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {D9906F1A-A41A-43CD-81D2-BA94CF0001C9}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {53134B0C-0D57-481B-B84E-D1991E8D54FF}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {53134B0C-0D57-481B-B84E-D1991E8D54FF}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {53134B0C-0D57-481B-B84E-D1991E8D54FF}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {99E1E564-0EF4-4E33-BECE-8ABE64771349} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {D9906F1A-A41A-43CD-81D2-BA94CF0001C9} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {53134B0C-0D57-481B-B84E-D1991E8D54FF} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {650277B5-9423-4ACE-BB54-2659995B21C7} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Configurations.props b/src/libraries/System.Numerics.Vectors/tests/Performance/Configurations.props deleted file mode 100644 index f5d3d45ffbf44..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp; - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.cs deleted file mode 100644 index a887935a6e62c..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.cs +++ /dev/null @@ -1,353 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Globalization; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using Xunit; -using Xunit.Sdk; -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static class Constructor - { - private static Random s_random = new Random(); - - public const int DefaultInnerIterationsCount = 100000000; - -#if netcoreapp - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_Byte() - { - byte[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_SByte() - { - sbyte[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_UInt16() - { - ushort[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_Int16() - { - short[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_UInt32() - { - uint[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_Int32() - { - int[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_UInt64() - { - ulong[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_Int64() - { - long[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_Single() - { - float[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_Double() - { - double[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new Span(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct(spanValues); - } - } - } - - public static void Construct(Span values) where T : struct - { - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - Vector vect = new Vector(values); - } - } -#endif - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_Byte() - { - byte[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_SByte() - { - sbyte[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_UInt16() - { - ushort[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_Int16() - { - short[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_UInt32() - { - uint[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_Int32() - { - int[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_UInt64() - { - ulong[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_Int64() - { - long[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_Single() - { - float[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_Double() - { - double[] arrValues = GenerateRandomValuesForVector(); - var spanValues = new ReadOnlySpan(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast(spanValues); - } - } - } - - - public static void SpanCast(ReadOnlySpan values) where T : struct - { - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - ReadOnlySpan> vectors = MemoryMarshal.Cast>(values); - Vector vector = vectors[0]; - } - } - - internal static T[] GenerateRandomValuesForVector() where T : struct - { - int minValue = GetMinValue(); - int maxValue = GetMaxValue(); - return Util.GenerateRandomValues(Vector.Count, minValue, maxValue); - } - - internal static int GetMinValue() where T : struct - { - if (typeof(T) == typeof(long) || typeof(T) == typeof(float) || typeof(T) == typeof(double) || typeof(T) == typeof(uint) || typeof(T) == typeof(ulong)) - { - return int.MinValue; - } - TypeInfo typeInfo = typeof(T).GetTypeInfo(); - FieldInfo field = typeInfo.GetDeclaredField("MinValue"); - var value = field.GetValue(null); - return (int)(dynamic)value; - } - - internal static int GetMaxValue() where T : struct - { - if (typeof(T) == typeof(long) || typeof(T) == typeof(float) || typeof(T) == typeof(double) || typeof(T) == typeof(uint) || typeof(T) == typeof(ulong)) - { - return int.MaxValue; - } - TypeInfo typeInfo = typeof(T).GetTypeInfo(); - FieldInfo field = typeInfo.GetDeclaredField("MaxValue"); - var value = field.GetValue(null); - return (int)(dynamic)value; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.tt b/src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.tt deleted file mode 100644 index 5fb58ea5a7849..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Constructor/GenericVectorConstructorTests.tt +++ /dev/null @@ -1,119 +0,0 @@ -<#@ template debug="true" hostSpecific="true" #> -<#@ output extension=".cs" #> -<#@ Assembly Name="System.Core.dll" #> -<#@ Assembly Name="System.Xml.dll" #> -<#@ import namespace="System" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Runtime.InteropServices" #> -<#@ include file="..\..\..\..\Common\src\CoreLib\System\Numerics\GenerationConfig.ttinclude" #><# GenerateCopyrightHeader(); #> - -using System; -using System.Globalization; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using Xunit; -using Xunit.Sdk; -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static class Constructor - { - private static Random s_random = new Random(); - - public const int DefaultInnerIterationsCount = 100000000; - -<# - foreach (var type in supportedTypes) - { -#> - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void ConstructorBenchmark_<#=type.Name#>() - { - <#=type.Name#>[] arrValues = GenerateRandomValuesForVector<<#=type.Name#>>(); - var spanValues = new Span<<#=type.Name#>>(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Construct<<#=type.Name#>>(spanValues); - } - } - } - -<# - } -#> - - public static void Construct(Span values) where T : struct - { - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - Vector vect = new Vector(values); - } - } - -<# - foreach (var type in supportedTypes) - { -#> - [Benchmark(InnerIterationCount = DefaultInnerIterationsCount)] - public static void SpanCastBenchmark_<#=type.Name#>() - { - <#=type.Name#>[] arrValues = GenerateRandomValuesForVector<<#=type.Name#>>(); - var spanValues = new ReadOnlySpan<<#=type.Name#>>(arrValues); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - SpanCast<<#=type.Name#>>(spanValues); - } - } - } - -<# - } -#> - - public static void SpanCast(ReadOnlySpan values) where T : struct - { - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - ReadOnlySpan> vectors = MemoryMarshal.Cast>(values); - Vector vector = vectors[0]; - } - } - - internal static T[] GenerateRandomValuesForVector() where T : struct - { - int minValue = GetMinValue(); - int maxValue = GetMaxValue(); - return Util.GenerateRandomValues(Vector.Count, minValue, maxValue); - } - - internal static int GetMinValue() where T : struct - { - if (typeof(T) == typeof(Int64) || typeof(T) == typeof(Single) || typeof(T) == typeof(Double) || typeof(T) == typeof(UInt32) || typeof(T) == typeof(UInt64)) - { - return int.MinValue; - } - TypeInfo typeInfo = typeof(T).GetTypeInfo(); - FieldInfo field = typeInfo.GetDeclaredField("MinValue"); - var value = field.GetValue(null); - return (int)(dynamic)value; - } - - internal static int GetMaxValue() where T : struct - { - if (typeof(T) == typeof(Int64) || typeof(T) == typeof(Single) || typeof(T) == typeof(Double) || typeof(T) == typeof(UInt32) || typeof(T) == typeof(UInt64)) - { - return int.MaxValue; - } - TypeInfo typeInfo = typeof(T).GetTypeInfo(); - FieldInfo field = typeInfo.GetDeclaredField("MaxValue"); - var value = field.GetValue(null); - return (int)(dynamic)value; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/System.Numerics.Vectors.PerformanceTests.csproj b/src/libraries/System.Numerics.Vectors/tests/Performance/System.Numerics.Vectors.PerformanceTests.csproj deleted file mode 100644 index ffb18ec371e66..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/System.Numerics.Vectors.PerformanceTests.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - true - {D9906F1A-A41A-43CD-81D2-BA94CF0001C9} - true - netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - - - TextTemplatingFileGenerator - GenericVectorConstructorTests.cs - - - - - Util.cs - - - True - True - GenericVectorConstructorTests.tt - - - - - GenerationConfig.ttinclude - - - \ No newline at end of file diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddFunction.cs deleted file mode 100644 index a97acc00aa5ac..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void AddFunctionBenchmark() - { - var expectedResult = VectorTests.Vector2Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = AddFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 AddFunctionTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector2.Add(result, VectorTests.Vector2Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddOperator.cs deleted file mode 100644 index f12798c866eb0..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/AddOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void AddOperatorBenchmark() - { - var expectedResult = VectorTests.Vector2Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = AddOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 AddOperatorTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += VectorTests.Vector2Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Distance.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Distance.cs deleted file mode 100644 index bace7ef1913af..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Distance.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceBenchmark() - { - const float expectedResult = 2.82842708f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector2.Distance(VectorTests.Vector2Value, VectorTests.Vector2ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceJitOptimizeCanaryBenchmark() - { - const float expectedResult = 67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector2Delta; - result += Vector2.Distance(value, VectorTests.Vector2ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/DistanceSquared.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/DistanceSquared.cs deleted file mode 100644 index f6ebd54ad3291..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/DistanceSquared.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceSquaredBenchmark() - { - const float expectedResult = 8.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceSquaredTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceSquaredTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector2.DistanceSquared(VectorTests.Vector2Value, VectorTests.Vector2ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceSquaredJitOptimizeCanaryBenchmark() - { - const float expectedResult = 134217728.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceSquaredJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceSquaredJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector2Delta; - result += Vector2.DistanceSquared(value, VectorTests.Vector2ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Dot.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Dot.cs deleted file mode 100644 index f3ba2a841c123..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Dot.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DotBenchmark() - { - const float expectedResult = -2.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DotTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DotTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector2.Dot(VectorTests.Vector2Value, VectorTests.Vector2ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DotJitOptimizeCanaryBenchmark() - { - const float expectedResult = -33554432.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DotJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DotJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector2Delta; - result += Vector2.Dot(value, VectorTests.Vector2ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/GetHashCode.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/GetHashCode.cs deleted file mode 100644 index e37cc2058fa0e..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/GetHashCode.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void GetHashCodeBenchmark() - { - const int expectedResult = -1879048169; - - foreach (var iteration in Benchmark.Iterations) - { - int actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = GetHashCodeTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static int GetHashCodeTest() - { - var result = 0; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector2Value.GetHashCode(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void GetHashCodeJitOptimizeCanaryBenchmark() - { - const int expectedResult = -1994967296; - - foreach (var iteration in Benchmark.Iterations) - { - int actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = GetHashCodeJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static int GetHashCodeJitOptimizeCanaryTest() - { - var result = 0; - var value = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector2Delta; - result += value.GetHashCode(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Length.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Length.cs deleted file mode 100644 index 7f9dc107cc6bc..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Length.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthBenchmark() - { - const float expectedResult = 1.41421354f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector2Value.Length(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthJitOptimizeCanaryBenchmark() - { - const float expectedResult = 33554432.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector2Delta; - result += value.Length(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/LengthSquared.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/LengthSquared.cs deleted file mode 100644 index 3c1452c2e1ff5..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/LengthSquared.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthSquaredBenchmark() - { - const float expectedResult = 2.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthSquaredTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthSquaredTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector2Value.LengthSquared(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthSquaredJitOptimizeCanaryBenchmark() - { - const float expectedResult = 33554432.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthSquaredJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthSquaredJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector2Delta; - result += value.LengthSquared(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyFunction.cs deleted file mode 100644 index 6eda7ee9f380d..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void MultiplyFunctionBenchmark() - { - var expectedResult = Vector2.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = MultiplyFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 MultiplyFunctionTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector2.Multiply(result, VectorTests.Vector2Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyOperator.cs deleted file mode 100644 index 9d0e384d61896..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/MultiplyOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void MultiplyOperatorBenchmark() - { - var expectedResult = Vector2.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = MultiplyOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 MultiplyOperatorTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result *= VectorTests.Vector2Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Normalize.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Normalize.cs deleted file mode 100644 index 74e492835fc34..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/Normalize.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void NormalizeBenchmark() - { - var expectedResult = new Vector2(-0.707106829f, 0.707106829f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = NormalizeTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 NormalizeTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector2.Normalize(result); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void NormalizeJitOptimizeCanaryBenchmark() - { - var expectedResult = new Vector2(-16777216.0f, 16777216.0f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = NormalizeJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 NormalizeJitOptimizeCanaryTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += Vector2.Normalize(result); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SquareRoot.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SquareRoot.cs deleted file mode 100644 index 8495c6e57181f..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SquareRoot.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SquareRootBenchmark() - { - var expectedResult = new Vector2(float.NaN, 1.0f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SquareRootTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 SquareRootTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector2.SquareRoot(result); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SquareRootJitOptimizeCanaryBenchmark() - { - var expectedResult = new Vector2(float.NaN, 2.81474977e+14f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SquareRootJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 SquareRootJitOptimizeCanaryTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += Vector2.SquareRoot(result); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractFunction.cs deleted file mode 100644 index efe7e8e6400ed..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SubtractFunctionBenchmark() - { - var expectedResult = VectorTests.Vector2Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SubtractFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 SubtractFunctionTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector2.Subtract(result, VectorTests.Vector2Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractOperator.cs deleted file mode 100644 index 2ec2ddf83c0bf..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector2/SubtractOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector2 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SubtractOperatorBenchmark() - { - var expectedResult = VectorTests.Vector2Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector2 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SubtractOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector2 SubtractOperatorTest() - { - var result = VectorTests.Vector2Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result -= VectorTests.Vector2Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddFunction.cs deleted file mode 100644 index 56ee4e4b37097..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void AddFunctionBenchmark() - { - var expectedResult = VectorTests.Vector3Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = AddFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 AddFunctionTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector3.Add(result, VectorTests.Vector3Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddOperator.cs deleted file mode 100644 index 875a87a35c1d3..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/AddOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void AddOperatorBenchmark() - { - var expectedResult = VectorTests.Vector3Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = AddOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 AddOperatorTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += VectorTests.Vector3Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Cross.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Cross.cs deleted file mode 100644 index 48037cbe13dd7..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Cross.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void CrossBenchmark() - { - var expectedResult = Vector3.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 result; - - using (iteration.StartMeasurement()) - { - result = CrossTest(); - } - - VectorTests.AssertEqual(expectedResult, result); - } - } - - public static Vector3 CrossTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector3.Cross(result, VectorTests.Vector3ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Distance.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Distance.cs deleted file mode 100644 index a4be2ede46d9d..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Distance.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceBenchmark() - { - const float expectedResult = 3.46410155f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector3.Distance(VectorTests.Vector3Value, VectorTests.Vector3ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceJitOptimizeCanaryBenchmark() - { - const float expectedResult = 67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector3Delta; - result += Vector3.Distance(value, VectorTests.Vector3ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/DistanceSquared.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/DistanceSquared.cs deleted file mode 100644 index 4b5f64ae4177a..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/DistanceSquared.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceSquaredBenchmark() - { - const float expectedResult = 12.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceSquaredTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceSquaredTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector3.DistanceSquared(VectorTests.Vector3Value, VectorTests.Vector3ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceSquaredJitOptimizeCanaryBenchmark() - { - const float expectedResult = 268435456.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceSquaredJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceSquaredJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector3Delta; - result += Vector3.DistanceSquared(value, VectorTests.Vector3ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Dot.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Dot.cs deleted file mode 100644 index 354a359574cda..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Dot.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DotBenchmark() - { - const float expectedResult = -3.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DotTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DotTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector3.Dot(VectorTests.Vector3Value, VectorTests.Vector3ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DotJitOptimizeCanaryBenchmark() - { - const float expectedResult = -67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float result; - - using (iteration.StartMeasurement()) - { - result = DotJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, result); - } - } - - public static float DotJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector3Delta; - result += Vector3.Dot(value, VectorTests.Vector3ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/GetHashCode.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/GetHashCode.cs deleted file mode 100644 index 4356a1a591e6c..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/GetHashCode.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void GetHashCodeBenchmark() - { - const int expectedResult = 796918537; - - foreach (var iteration in Benchmark.Iterations) - { - int actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = GetHashCodeTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static int GetHashCodeTest() - { - var result = 0; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector3Value.GetHashCode(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void GetHashCodeJitOptimizeCanaryBenchmark() - { - const int expectedResult = -1756894976; - - foreach (var iteration in Benchmark.Iterations) - { - int actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = GetHashCodeJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static int GetHashCodeJitOptimizeCanaryTest() - { - var result = 0; - var value = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector3Delta; - result += value.GetHashCode(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Length.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Length.cs deleted file mode 100644 index 85113cf858888..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Length.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthBenchmark() - { - const float expectedResult = 1.73205078f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector3Value.Length(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthJitOptimizeCanaryBenchmark() - { - const float expectedResult = 33554432.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector3Delta; - result += value.Length(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/LengthSquared.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/LengthSquared.cs deleted file mode 100644 index 4fcddddc0b687..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/LengthSquared.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthSquaredBenchmark() - { - const float expectedResult = 3.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthSquaredTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthSquaredTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector3Value.LengthSquared(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthSquaredJitOptimizeCanaryBenchmark() - { - const float expectedResult = 67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthSquaredJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthSquaredJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector3Delta; - result += value.LengthSquared(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyFunction.cs deleted file mode 100644 index e7de5ab0db3f6..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void MultiplyFunctionBenchmark() - { - var expectedResult = Vector3.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = MultiplyFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 MultiplyFunctionTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector3.Multiply(result, VectorTests.Vector3Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyOperator.cs deleted file mode 100644 index 26069f76ba400..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/MultiplyOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void MultiplyOperatorBenchmark() - { - var expectedResult = Vector3.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = MultiplyOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 MultiplyOperatorTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result *= VectorTests.Vector3Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Normalize.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Normalize.cs deleted file mode 100644 index 1b9ed4967b91f..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/Normalize.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void NormalizeBenchmark() - { - var expectedResult = new Vector3(-0.577350318f, 0.577350318f, -0.577350318f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = NormalizeTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 NormalizeTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector3.Normalize(result); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void NormalizeJitOptimizeCanaryBenchmark() - { - var expectedResult = new Vector3(-16777216.0f, 16777216.0f, -16777216.0f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = NormalizeJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 NormalizeJitOptimizeCanaryTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += Vector3.Normalize(result); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SquareRoot.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SquareRoot.cs deleted file mode 100644 index 90bf32896dccc..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SquareRoot.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SquareRootBenchmark() - { - var expectedResult = new Vector3(float.NaN, 1.0f, float.NaN); - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SquareRootTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 SquareRootTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector3.SquareRoot(result); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SquareRootJitOptimizeCanaryBenchmark() - { - var expectedResult = new Vector3(float.NaN, 2.81474977e+14f, float.NaN); - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SquareRootJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 SquareRootJitOptimizeCanaryTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += Vector3.SquareRoot(result); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractFunction.cs deleted file mode 100644 index 2c0e6c3a84bc4..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SubtractFunctionBenchmark() - { - var expectedResult = VectorTests.Vector3Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SubtractFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 SubtractFunctionTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector3.Subtract(result, VectorTests.Vector3Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractOperator.cs deleted file mode 100644 index 4cf0ebad559ad..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector3/SubtractOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector3 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SubtractOperatorBenchmark() - { - var expectedResult = VectorTests.Vector3Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector3 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SubtractOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector3 SubtractOperatorTest() - { - var result = VectorTests.Vector3Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result -= VectorTests.Vector3Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddFunction.cs deleted file mode 100644 index f0549478d9e0b..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void AddFunctionBenchmark() - { - var expectedResult = VectorTests.Vector4Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = AddFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 AddFunctionTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector4.Add(result, VectorTests.Vector4Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddOperator.cs deleted file mode 100644 index c97864805acd3..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/AddOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void AddOperatorBenchmark() - { - var expectedResult = VectorTests.Vector4Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = AddOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 AddOperatorTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += VectorTests.Vector4Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Distance.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Distance.cs deleted file mode 100644 index f42271a5a3337..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Distance.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceBenchmark() - { - const float expectedResult = 4.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector4.Distance(VectorTests.Vector4Value, VectorTests.Vector4ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceJitOptimizeCanaryBenchmark() - { - const float expectedResult = 67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector4Delta; - result += Vector4.Distance(value, VectorTests.Vector4ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/DistanceSquared.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/DistanceSquared.cs deleted file mode 100644 index e67eb0ca7127c..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/DistanceSquared.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceSquaredBenchmark() - { - const float expectedResult = 16.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceSquaredTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceSquaredTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector4.DistanceSquared(VectorTests.Vector4Value, VectorTests.Vector4ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DistanceSquaredJitOptimizeCanaryBenchmark() - { - const float expectedResult = 268435456.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DistanceSquaredJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DistanceSquaredJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector4Delta; - result += Vector4.DistanceSquared(value, VectorTests.Vector4ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Dot.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Dot.cs deleted file mode 100644 index d89ef31f2315d..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Dot.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DotBenchmark() - { - const float expectedResult = -4.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DotTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DotTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector4.Dot(VectorTests.Vector4Value, VectorTests.Vector4ValueInverted); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void DotJitOptimizeCanaryBenchmark() - { - const float expectedResult = -67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = DotJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float DotJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector4Delta; - result += Vector4.Dot(value, VectorTests.Vector4ValueInverted); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/GetHashCode.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/GetHashCode.cs deleted file mode 100644 index 8403eab226633..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/GetHashCode.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void GetHashCodeBenchmark() - { - const int expectedResult = 536896558; - - foreach (var iteration in Benchmark.Iterations) - { - int actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = GetHashCodeTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static int GetHashCodeTest() - { - var result = 0; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector4Value.GetHashCode(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void GetHashCodeJitOptimizeCanaryBenchmark() - { - const int expectedResult = 504524288; - - foreach (var iteration in Benchmark.Iterations) - { - int actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = GetHashCodeJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static int GetHashCodeJitOptimizeCanaryTest() - { - var result = 0; - var value = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector4Delta; - result += value.GetHashCode(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Length.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Length.cs deleted file mode 100644 index 59ffb85bd3c82..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Length.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthBenchmark() - { - const float expectedResult = 2.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector4Value.Length(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthJitOptimizeCanaryBenchmark() - { - const float expectedResult = 33554432.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector4Delta; - result += value.Length(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/LengthSquared.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/LengthSquared.cs deleted file mode 100644 index 7e74e5b0a9a6e..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/LengthSquared.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthSquaredBenchmark() - { - const float expectedResult = 4.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthSquaredTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthSquaredTest() - { - var result = 0.0f; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = VectorTests.Vector4Value.LengthSquared(); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void LengthSquaredJitOptimizeCanaryBenchmark() - { - const float expectedResult = 67108864.0f; - - foreach (var iteration in Benchmark.Iterations) - { - float actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = LengthSquaredJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static float LengthSquaredJitOptimizeCanaryTest() - { - var result = 0.0f; - var value = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - value += VectorTests.Vector4Delta; - result += value.LengthSquared(); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyFunction.cs deleted file mode 100644 index 30ec1dcfaff5f..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void MultiplyFunctionBenchmark() - { - var expectedResult = Vector4.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = MultiplyFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 MultiplyFunctionTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector4.Multiply(result, VectorTests.Vector4Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyOperator.cs deleted file mode 100644 index fc5d876d8c2fe..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/MultiplyOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void MultiplyOperatorBenchmark() - { - var expectedResult = Vector4.Zero; - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = MultiplyOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 MultiplyOperatorTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result *= VectorTests.Vector4Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Normalize.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Normalize.cs deleted file mode 100644 index 84f5a56819939..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/Normalize.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void NormalizeBenchmark() - { - var expectedResult = new Vector4(-0.5f, 0.5f, -0.5f, 0.5f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = NormalizeTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 NormalizeTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector4.Normalize(result); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void NormalizeJitOptimizeCanaryBenchmark() - { - var expectedResult = new Vector4(-8388608.0f, 8388608.0f, -8388608.0f, 8388608.0f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = NormalizeJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 NormalizeJitOptimizeCanaryTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += Vector4.Normalize(result); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SquareRoot.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SquareRoot.cs deleted file mode 100644 index e6fc1549b6e44..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SquareRoot.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SquareRootBenchmark() - { - var expectedResult = new Vector4(float.NaN, 1.0f, float.NaN, 1.0f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SquareRootTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 SquareRootTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - // The inputs aren't being changed and the output is being reset with each iteration, so a future - // optimization could potentially throw away everything except for the final call. This would break - // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. - result = Vector4.SquareRoot(result); - } - - return result; - } - - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SquareRootJitOptimizeCanaryBenchmark() - { - var expectedResult = new Vector4(float.NaN, 2.81474977e+14f, float.NaN, 2.81474977e+14f); - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SquareRootJitOptimizeCanaryTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 SquareRootJitOptimizeCanaryTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result += Vector4.SquareRoot(result); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractFunction.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractFunction.cs deleted file mode 100644 index 435bb0faccf63..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractFunction.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SubtractFunctionBenchmark() - { - var expectedResult = VectorTests.Vector4Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SubtractFunctionTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 SubtractFunctionTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result = Vector4.Subtract(result, VectorTests.Vector4Delta); - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractOperator.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractOperator.cs deleted file mode 100644 index c6be814017584..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/Vector4/SubtractOperator.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Numerics.Tests -{ - public static partial class Perf_Vector4 - { - [Benchmark(InnerIterationCount = VectorTests.DefaultInnerIterationsCount)] - public static void SubtractOperatorBenchmark() - { - var expectedResult = VectorTests.Vector4Value; - - foreach (var iteration in Benchmark.Iterations) - { - Vector4 actualResult; - - using (iteration.StartMeasurement()) - { - actualResult = SubtractOperatorTest(); - } - - VectorTests.AssertEqual(expectedResult, actualResult); - } - } - - public static Vector4 SubtractOperatorTest() - { - var result = VectorTests.Vector4Value; - - for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) - { - result -= VectorTests.Vector4Delta; - } - - return result; - } - } -} diff --git a/src/libraries/System.Numerics.Vectors/tests/Performance/VectorTests.cs b/src/libraries/System.Numerics.Vectors/tests/Performance/VectorTests.cs deleted file mode 100644 index 52d800bbf403b..0000000000000 --- a/src/libraries/System.Numerics.Vectors/tests/Performance/VectorTests.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Diagnostics; - -namespace System.Numerics.Tests -{ - public static class VectorTests - { - public const int DefaultInnerIterationsCount = 100000000; - - #region Single Helper Values - // float has a machine epsilon of approx: 1.19e-07. However, due to floating-point precision - // errors, this is too accurate when aggregating values of a set of iterations. Using the - // half-precision machine epsilon as our epsilon should be 'good enough' for the purposes - // of the perf testing as it ensures we get the expected value and that it is at least as precise - // as we would have computed with the half-precision version of the function (without aggregation). - public const float SingleEpsilon = 9.77e-04f; - - public const float SinglePositiveDelta = 1.0f / DefaultInnerIterationsCount; - - public const float SingleNegativeDelta = -1.0f / DefaultInnerIterationsCount; - #endregion - - #region Vector2 Helper Values - public static readonly Vector2 Vector2Delta = new Vector2(SinglePositiveDelta, SingleNegativeDelta); - - public static readonly Vector2 Vector2Value = new Vector2(-1.0f, 1.0f); - - public static readonly Vector2 Vector2ValueInverted = new Vector2(1.0f, -1.0f); - #endregion - - #region Vector3 Helper Values - public static readonly Vector3 Vector3Delta = new Vector3(SinglePositiveDelta, SingleNegativeDelta, SinglePositiveDelta); - - public static readonly Vector3 Vector3Value = new Vector3(-1.0f, 1.0f, -1.0f); - - public static readonly Vector3 Vector3ValueInverted = new Vector3(1.0f, -1.0f, 1.0f); - #endregion - - #region Vector4 Helper Values - public static readonly Vector4 Vector4Delta = new Vector4(SinglePositiveDelta, SingleNegativeDelta, SinglePositiveDelta, SingleNegativeDelta); - - public static readonly Vector4 Vector4Value = new Vector4(-1.0f, 1.0f, -1.0f, 1.0f); - - public static readonly Vector4 Vector4ValueInverted = new Vector4(1.0f, -1.0f, 1.0f, -1.0f); - #endregion - - #region Assert Helpers - public static void AssertEqual(float expectedResult, float actualResult) - { - if (!SingleAreEqual(expectedResult, actualResult)) - { - throw new Exception($"Expected Result: {expectedResult:g9}; Actual Result: {actualResult:g9}"); - } - } - - public static void AssertEqual(int expectedResult, int actualResult) - { - if (expectedResult != actualResult) - { - throw new Exception($"Expected Result: {expectedResult}; Actual Result: {actualResult}"); - } - } - - public static void AssertEqual(Vector2 expectedResult, Vector2 actualResult) - { - if (!SingleAreEqual(expectedResult.X, actualResult.X) || - !SingleAreEqual(expectedResult.Y, actualResult.Y)) - { - throw new Exception($"Expected Result: {expectedResult:g9}; Actual Result: {actualResult:g9}"); - } - } - - public static void AssertEqual(Vector3 expectedResult, Vector3 actualResult) - { - if (!SingleAreEqual(expectedResult.X, actualResult.X) || - !SingleAreEqual(expectedResult.Y, actualResult.Y) || - !SingleAreEqual(expectedResult.Z, actualResult.Z)) - { - throw new Exception($"Expected Result: {expectedResult:g9}; Actual Result: {actualResult:g9}"); - } - } - - public static void AssertEqual(Vector4 expectedResult, Vector4 actualResult) - { - if (!SingleAreEqual(expectedResult.X, actualResult.X) || - !SingleAreEqual(expectedResult.Y, actualResult.Y) || - !SingleAreEqual(expectedResult.Z, actualResult.Z) || - !SingleAreEqual(expectedResult.W, actualResult.W)) - { - throw new Exception($"Expected Result: {expectedResult:g9}; Actual Result: {actualResult:g9}"); - } - } - - public static bool SingleAreEqual(float expectedResult, float actualResult) - { - if (float.IsNaN(expectedResult)) - { - return float.IsNaN(actualResult); - } - else if (float.IsNaN(actualResult)) - { - // expectedResult is finite - return false; - } - else - { - var diff = Math.Abs(expectedResult - actualResult); - return (diff <= SingleEpsilon); - } - } - #endregion - } -} From fed8132ca5877bc0fa0cc88ea7675d429431bf76 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:47:39 +0100 Subject: [PATCH 24/45] remove System.Runtime.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/e622f40a10fa964c2b3394da1506524d204e0b0b --- .../System.Runtime/System.Runtime.sln | 10 - .../tests/Performance/Configurations.props | 8 - .../tests/Performance/Perf.Array.cs | 430 ------- .../tests/Performance/Perf.Boolean.cs | 38 - .../tests/Performance/Perf.Char.cs | 66 -- .../tests/Performance/Perf.DateTime.cs | 69 -- .../tests/Performance/Perf.Decimal.cs | 30 - .../tests/Performance/Perf.Double.cs | 198 ---- .../tests/Performance/Perf.Enum.cs | 30 - .../tests/Performance/Perf.Guid.cs | 38 - .../Performance/Perf.HashCode.netcoreapp.cs | 209 ---- .../tests/Performance/Perf.Int32.cs | 91 -- .../tests/Performance/Perf.Int64.cs | 126 --- .../tests/Performance/Perf.IntPtr.cs | 40 - .../tests/Performance/Perf.Object.cs | 38 - .../tests/Performance/Perf.Single.cs | 198 ---- .../tests/Performance/Perf.String.cs | 1007 ----------------- .../Performance/Perf.String.netcoreapp.cs | 33 - .../tests/Performance/Perf.StringBuilder.cs | 190 ---- .../tests/Performance/Perf.TimeSpan.cs | 37 - .../tests/Performance/Perf.Type.cs | 41 - .../tests/Performance/Perf.UInt32.cs | 81 -- .../tests/Performance/Perf.UInt64.cs | 100 -- .../System.Runtime.PerformanceTests.csproj | 42 - 24 files changed, 3150 deletions(-) delete mode 100644 src/libraries/System.Runtime/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Array.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Boolean.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Char.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.DateTime.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Decimal.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Double.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Enum.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Guid.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.HashCode.netcoreapp.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Int32.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Int64.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.IntPtr.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Object.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Single.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.String.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.String.netcoreapp.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.StringBuilder.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.TimeSpan.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.Type.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.UInt32.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/Perf.UInt64.cs delete mode 100644 src/libraries/System.Runtime/tests/Performance/System.Runtime.PerformanceTests.csproj diff --git a/src/libraries/System.Runtime/System.Runtime.sln b/src/libraries/System.Runtime/System.Runtime.sln index 809839c622986..72bd9a8bc687f 100644 --- a/src/libraries/System.Runtime/System.Runtime.sln +++ b/src/libraries/System.Runtime/System.Runtime.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ForwardedTypesAssembly", "t {56B9D0A9-44D3-488E-8B42-C14A6E30CAB2} = {56B9D0A9-44D3-488E-8B42-C14A6E30CAB2} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.PerformanceTests", "tests\Performance\System.Runtime.PerformanceTests.csproj", "{E9560F70-79F5-453A-B518-0292CFE4A6AD}" - ProjectSection(ProjectDependencies) = postProject - {56B9D0A9-44D3-488E-8B42-C14A6E30CAB2} = {56B9D0A9-44D3-488E-8B42-C14A6E30CAB2} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAssembly", "tests\TestAssembly\TestAssembly.csproj", "{2EF7D710-A7BD-4BB3-8EF6-3F0298CD4986}" ProjectSection(ProjectDependencies) = postProject {56B9D0A9-44D3-488E-8B42-C14A6E30CAB2} = {56B9D0A9-44D3-488E-8B42-C14A6E30CAB2} @@ -64,10 +59,6 @@ Global {3A3DE9F8-6295-4B68-BAAB-406F1CA0CD9C}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {3A3DE9F8-6295-4B68-BAAB-406F1CA0CD9C}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {3A3DE9F8-6295-4B68-BAAB-406F1CA0CD9C}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {E9560F70-79F5-453A-B518-0292CFE4A6AD}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {E9560F70-79F5-453A-B518-0292CFE4A6AD}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {E9560F70-79F5-453A-B518-0292CFE4A6AD}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {E9560F70-79F5-453A-B518-0292CFE4A6AD}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {2EF7D710-A7BD-4BB3-8EF6-3F0298CD4986}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU {2EF7D710-A7BD-4BB3-8EF6-3F0298CD4986}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {2EF7D710-A7BD-4BB3-8EF6-3F0298CD4986}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU @@ -99,7 +90,6 @@ Global GlobalSection(NestedProjects) = preSolution {B1BF7CE0-CAB5-4FA2-A39C-450B05D5DB1C} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {3A3DE9F8-6295-4B68-BAAB-406F1CA0CD9C} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {E9560F70-79F5-453A-B518-0292CFE4A6AD} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {2EF7D710-A7BD-4BB3-8EF6-3F0298CD4986} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {71DE1A1F-F8E2-452A-9D54-0385F6099DD3} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {3B7489C4-65DB-4E69-BE01-F6234133400C} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} diff --git a/src/libraries/System.Runtime/tests/Performance/Configurations.props b/src/libraries/System.Runtime/tests/Performance/Configurations.props deleted file mode 100644 index f5d3d45ffbf44..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp; - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Array.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Array.cs deleted file mode 100644 index 9d9e17aaa74f7..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Array.cs +++ /dev/null @@ -1,430 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using System; - -namespace System.Tests -{ - public class Perf_Array - { - private static int[] s_arr; - private static Array s_arr1; - private static Array s_arr2; - private static Array s_arr3; - - private const int MAX_ARRAY_SIZE = 4096; - - private static readonly int s_DIM_1 = MAX_ARRAY_SIZE; - private static readonly int s_DIM_2 = (int)Math.Pow(MAX_ARRAY_SIZE, (1.0 / 2.0)); - private static readonly int s_DIM_3 = (int)(Math.Pow(MAX_ARRAY_SIZE, (1.0 / 3.0)) + .001); - - [Benchmark] - public static void ArrayCreate() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s_arr = new int[s_DIM_1]; - } - - [Benchmark] - public static void ArrayCopy() - { - int[] dummy = new int[s_DIM_1]; - s_arr = new int[s_DIM_1]; - - for (int i = 0; i < s_DIM_1; i++) - s_arr[i] = i; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_1; j++) - { - dummy[j] = s_arr[j]; - } - } - } - } - - [Benchmark] - public static void ArrayAssign() - { - s_arr = new int[s_DIM_1]; - - for (int j = 0; j < s_DIM_1; j++) - s_arr[j] = j; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_1; j++) - { - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - s_arr[j] = j; - } - } - } - } - - [Benchmark] - public static void ArrayRetrieve() - { - int value; - s_arr = new int[s_DIM_1]; - - for (int i = 0; i < s_DIM_1; i++) - s_arr[i] = i; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_1; j++) - { - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - value = s_arr[j]; - } - } - } - } - - [Benchmark] - public static void ArrayCreate1D() - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - s_arr1 = Array.CreateInstance(typeof(int), s_DIM_1); - } - } - } - - [Benchmark] - public static void ArrayCreate2D() - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - s_arr2 = Array.CreateInstance(typeof(int), s_DIM_2, s_DIM_2); - } - } - } - - [Benchmark] - public static void ArrayCreate3D() - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - s_arr3 = Array.CreateInstance(typeof(int), s_DIM_3, s_DIM_3, s_DIM_3); - } - } - } - - [Benchmark] - public static void ArrayAssign1D() - { - s_arr1 = Array.CreateInstance(typeof(int), s_DIM_1); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_1; j++) - { - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - s_arr1.SetValue(j, j); - } - } - } - } - - [Benchmark] - public static void ArrayAssign2D() - { - s_arr2 = Array.CreateInstance(typeof(int), s_DIM_2, s_DIM_2); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_2; j++) - { - for (int k = 0; k < s_DIM_2; k++) - { - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - s_arr2.SetValue(j + k, j, k); - } - } - } - } - } - - [Benchmark] - public static void ArrayAssign3D() - { - s_arr3 = Array.CreateInstance(typeof(int), s_DIM_3, s_DIM_3, s_DIM_3); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_3; j++) - { - for (int k = 0; k < s_DIM_3; k++) - { - for (int l = 0; l < s_DIM_3; l++) - { - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - s_arr3.SetValue(j + k + l, j, k, l); - } - } - } - } - } - } - - [Benchmark] - public static void ArrayRetrieve1D() - { - int value; - s_arr1 = Array.CreateInstance(typeof(int), s_DIM_1); - - for (int i = 0; i < s_DIM_1; i++) - s_arr1.SetValue(i, i); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_1; j++) - { - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - value = (int)s_arr1.GetValue(j); - } - } - } - } - - [Benchmark] - public static void ArrayRetrieve2D() - { - int value; - s_arr2 = Array.CreateInstance(typeof(int), s_DIM_2, s_DIM_2); - - for (int i = 0; i < s_DIM_2; i++) - { - for (int j = 0; j < s_DIM_2; j++) - s_arr2.SetValue(i + j, i, j); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_2; j++) - { - for (int k = 0; k < s_DIM_2; k++) - { - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - value = (int)s_arr2.GetValue(j, k); - } - } - } - } - } - - [Benchmark] - public static void ArrayRetrieve3D() - { - int value; - s_arr3 = Array.CreateInstance(typeof(int), s_DIM_3, s_DIM_3, s_DIM_3); - - for (int i = 0; i < s_DIM_3; i++) - { - for (int j = 0; j < s_DIM_3; j++) - { - for (int k = 0; k < s_DIM_3; k++) - s_arr3.SetValue(i + j + k, i, j, k); - } - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s_DIM_3; j++) - { - for (int k = 0; k < s_DIM_3; k++) - { - for (int l = 0; l < s_DIM_3; l++) - { - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - value = (int)s_arr3.GetValue(j, k, l); - } - } - } - } - } - } - - [Benchmark] - public static void ArrayCopy1D() - { - Array dummy = Array.CreateInstance(typeof(int), s_DIM_1); - s_arr1 = Array.CreateInstance(typeof(int), s_DIM_1); - - for (int i = 0; i < s_DIM_1; i++) - s_arr1.SetValue(i, i); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Array.Copy(s_arr1, dummy, MAX_ARRAY_SIZE); - } - } - } - - [Benchmark] - public static void ArrayCopy2D() - { - int arrayLen = (int)Math.Pow(s_DIM_2, 2); - - Array dummy = Array.CreateInstance(typeof(int), s_DIM_2, s_DIM_2); - s_arr2 = Array.CreateInstance(typeof(int), s_DIM_2, s_DIM_2); - - for (int i = 0; i < s_DIM_2; i++) - { - for (int j = 0; j < s_DIM_2; j++) - s_arr2.SetValue(i + j, i, j); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Array.Copy(s_arr2, dummy, arrayLen); - } - } - } - - [Benchmark] - public static void ArrayCopy3D() - { - int arrayLen = (int)Math.Pow(s_DIM_3, 3); - - Array dummy = Array.CreateInstance(typeof(int), s_DIM_3, s_DIM_3, s_DIM_3); - s_arr3 = Array.CreateInstance(typeof(int), s_DIM_3, s_DIM_3, s_DIM_3); - - for (int i = 0; i < s_DIM_3; i++) - { - for (int j = 0; j < s_DIM_3; j++) - { - for (int k = 0; k < s_DIM_3; k++) - { - s_arr3.SetValue(i + j + k, i, j, k); - } - } - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - Array.Copy(s_arr3, dummy, arrayLen); - } - } - } - - [Benchmark] - public static void ArrayResize() - { - // Test copying a subarray - const int oldSize = 42; - const int newSize = 41; - - foreach (var iteration in Benchmark.Iterations) - { - byte[] ary = new byte[oldSize]; - - using (iteration.StartMeasurement()) - { - Array.Resize(ref ary, newSize); - } - } - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Boolean.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Boolean.cs deleted file mode 100644 index 2590ab9d238a5..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Boolean.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Boolean - { - [Benchmark] - public void Parse_str() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - bool.Parse("True"); bool.Parse("True"); bool.Parse("True"); - bool.Parse("True"); bool.Parse("True"); bool.Parse("True"); - bool.Parse("True"); bool.Parse("True"); bool.Parse("True"); - } - } - - [Benchmark] - public void ToString_() - { - bool boo = true; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - boo.ToString(); boo.ToString(); boo.ToString(); - boo.ToString(); boo.ToString(); boo.ToString(); - boo.ToString(); boo.ToString(); boo.ToString(); - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Char.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Char.cs deleted file mode 100644 index 4d2e835d9ba58..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Char.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Globalization; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_Char - { - private const int InnerIterations = 1_000_000; - - public static IEnumerable Char_ChangeCase_MemberData() - { - yield return new object[] { 'A', "en-US" }; // ASCII upper case - yield return new object[] { 'a', "en-US" }; // ASCII lower case - yield return new object[] { '\u0130', "en-US" }; // non-ASCII, English - yield return new object[] { '\u4F60', "zh-Hans" }; // non-ASCII, Chinese - } - - [Benchmark(InnerIterationCount = InnerIterations)] - [MemberData(nameof(Char_ChangeCase_MemberData))] - public static char Char_ToLower(char c, string cultureName) - { - char ret = default(char); - CultureInfo culture = new CultureInfo(cultureName); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerIterations; i++) - { - ret = char.ToLower(c, culture); - } - } - } - - return ret; - } - - [Benchmark(InnerIterationCount = InnerIterations)] - [MemberData(nameof(Char_ChangeCase_MemberData))] - public static char Char_ToUpper(char c, string cultureName) - { - char ret = default(char); - CultureInfo culture = new CultureInfo(cultureName); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerIterations; i++) - { - ret = char.ToUpper(c, culture); - } - } - } - - return ret; - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.DateTime.cs b/src/libraries/System.Runtime/tests/Performance/Perf.DateTime.cs deleted file mode 100644 index d1a8b302a697f..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.DateTime.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_DateTime - { - [Benchmark] - public void GetNow() - { - DateTime dt; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - dt = DateTime.Now; dt = DateTime.Now; dt = DateTime.Now; - dt = DateTime.Now; dt = DateTime.Now; dt = DateTime.Now; - dt = DateTime.Now; dt = DateTime.Now; dt = DateTime.Now; - } - } - - [Benchmark] - public void GetUtcNow() - { - DateTime dt; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - dt = DateTime.UtcNow; dt = DateTime.UtcNow; dt = DateTime.UtcNow; - dt = DateTime.UtcNow; dt = DateTime.UtcNow; dt = DateTime.UtcNow; - dt = DateTime.UtcNow; dt = DateTime.UtcNow; dt = DateTime.UtcNow; - } - } - - [Benchmark] - public void ToString_str() - { - DateTime dt = DateTime.Now; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - dt.ToString("g"); dt.ToString("g"); dt.ToString("g"); - dt.ToString("g"); dt.ToString("g"); dt.ToString("g"); - dt.ToString("g"); dt.ToString("g"); dt.ToString("g"); - } - } - - [Benchmark] - public void op_Subtraction() - { - TimeSpan result; - DateTime date1 = new DateTime(1996, 6, 3, 22, 15, 0); - DateTime date2 = new DateTime(1996, 12, 6, 13, 2, 0); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 100000; i++) - { - result = date1 - date2; result = date1 - date2; result = date1 - date2; - result = date1 - date2; result = date1 - date2; result = date1 - date2; - result = date1 - date2; result = date1 - date2; result = date1 - date2; - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Decimal.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Decimal.cs deleted file mode 100644 index 7bcbef341b6a5..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Decimal.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Decimal - { - private volatile string _string; - - [Benchmark(InnerIterationCount = 4_000_000)] - public void DefaultToString() - { - decimal number = new decimal(1.23456789E+5); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - _string = number.ToString(); - } - } - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Double.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Double.cs deleted file mode 100644 index a022df64f8b2c..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Double.cs +++ /dev/null @@ -1,198 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Globalization; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_Double - { - // NOTE: Consider duplicating any tests added here in Perf.Single.cs - - private volatile string _string; - private volatile bool _bool; - - // Reenable commented out test cases when https://github.com/xunit/xunit/issues/1822 is fixed. - [Benchmark] - [InlineData(double.NegativeInfinity, 10_000_000)] // Negative Infinity - [InlineData(double.MinValue, 100_000)] // Min Negative Normal - [InlineData(-3.14159265358979324, 1_000_000)] // Negative pi - [InlineData(-2.71828182845904524, 1_000_000)] // Negative e - [InlineData(-1.0, 1_000_000)] // Negative One - // [InlineData(-2.2250738585072014E-308, 100_000)] // Max Negative Normal - [InlineData(-2.2250738585072009E-308, 100_000)] // Min Negative Subnormal - [InlineData(-double.Epsilon, 100_000)] // Max Negative Subnormal (Negative Epsilon) - [InlineData(-0.0, 10_000_000)] // Negative Zero - [InlineData(double.NaN, 10_000_000)] // NaN - [InlineData(0.0, 10_000_000)] // Positive Zero - [InlineData(double.Epsilon, 100_000)] // Min Positive Subnormal (Positive Epsilon) - [InlineData(2.2250738585072009E-308, 100_000)] // Max Positive Subnormal - // [InlineData(2.2250738585072014E-308, 100_000)] // Min Positive Normal - [InlineData(1.0, 1_000_000)] // Positive One - [InlineData(2.71828182845904524, 1_000_000)] // Positive e - [InlineData(3.14159265358979324, 1_000_000)] // Positive pi - [InlineData(double.MaxValue, 100_000)] // Max Positive Normal - [InlineData(double.PositiveInfinity, 10_000_000)] // Positive Infinity - public void DefaultToString(double number, int innerIterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _string = number.ToString(); - } - } - } - } - - [Benchmark] - [InlineData("-∞", 10_000_000)] // Negative Infinity - [InlineData("-1.7976931348623157E+308", 100_000)] // Min Negative Normal - [InlineData("-3.1415926535897931", 1_000_000)] // Negative pi - [InlineData("-2.7182818284590451", 1_000_000)] // Negative e - [InlineData("-1", 1_000_000)] // Negative One - // [InlineData("-2.2250738585072014E-308", 100_000)] // Max Negative Normal - [InlineData("-2.2250738585072009E-308", 100_000)] // Min Negative Subnormal - [InlineData("-4.94065645841247E-324", 100_000)] // Max Negative Subnormal (Negative Epsilon) - [InlineData("-0.0", 10_000_000)] // Negative Zero - [InlineData("NaN", 10_000_000)] // NaN - [InlineData("0", 10_000_000)] // Positive Zero - [InlineData("4.94065645841247E-324", 100_000)] // Min Positive Subnormal (Positive Epsilon) - [InlineData("2.2250738585072009E-308", 100_000)] // Max Positive Subnormal - // [InlineData("2.2250738585072014E-308", 100_000)] // Min Positive Normal - [InlineData("1", 1_000_000)] // Positive One - [InlineData("2.7182818284590451", 1_000_000)] // Positive e - [InlineData("3.1415926535897931", 1_000_000)] // Positive pi - [InlineData("1.7976931348623157E+308", 100_000)] // Max Positive Normal - [InlineData("∞", 10_000_000)] // Positive Infinity - public void DefaultTryParse(string input, int innerIterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _bool = double.TryParse(input, out var result); - } - } - } - } - - [Benchmark] - [InlineData("zh", double.NegativeInfinity, 10_000_000)] // Negative Infinity - [InlineData("zh", double.MinValue, 100_000)] // Min Negative Normal - [InlineData("zh", -3.14159265358979324, 1_000_000)] // Negative pi - [InlineData("zh", -2.71828182845904524, 1_000_000)] // Negative e - [InlineData("zh", -1.0, 1_000_000)] // Negative One - // [InlineData("zh", -2.2250738585072014E-308, 100_000)] // Max Negative Normal - [InlineData("zh", -2.2250738585072009E-308, 100_000)] // Min Negative Subnormal - [InlineData("zh", -double.Epsilon, 100_000)] // Max Negative Subnormal (Negative Epsilon) - [InlineData("zh", -0.0, 10_000_000)] // Negative Zero - [InlineData("zh", double.NaN, 10_000_000)] // NaN - [InlineData("zh", 0.0, 10_000_000)] // Positive Zero - [InlineData("zh", double.Epsilon, 100_000)] // Min Positive Subnormal (Positive Epsilon) - [InlineData("zh", 2.2250738585072009E-308, 100_000)] // Max Positive Subnormal - // [InlineData("zh", 2.2250738585072014E-308, 100_000)] // Min Positive Normal - [InlineData("zh", 1.0, 1_000_000)] // Positive One - [InlineData("zh", 2.71828182845904524, 1_000_000)] // Positive e - [InlineData("zh", 3.14159265358979324, 1_000_000)] // Positive pi - [InlineData("zh", double.MaxValue, 100_000)] // Max Positive Normal - [InlineData("zh", double.PositiveInfinity, 10_000_000)] // Positive Infinity - public void ToStringWithCultureInfo(string cultureName, double number, int innerIterations) - { - CultureInfo cultureInfo = new CultureInfo(cultureName); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _string = number.ToString(cultureInfo); - } - } - } - } - - public static IEnumerable ToStringWithFormat_TestData() - { - string[] formats = - { - "R", // Roundtrip - "E", // Exponential - "F", // Fixed Point - }; - - double[] specialTestValues = // 10_000_000 iterations - { - double.NegativeInfinity, // Negative Infinity - -0.0, // Negative Zero - double.NaN, // NaN - 0.0, // Positive Zero - double.PositiveInfinity, // Positive Infinity - }; - - double[] normalTestValues = // 1_000_000 iterations - { - -3.14159265358979324, // Negative pi - -2.71828182845904524, // Negative e - -1.0, // Negative One - 1.0, // Positive One - 2.71828182845904524, // Positive e - 3.14159265358979324, // Positive pi - }; - - double[] edgeTestValues = // 100_000 iterations - { - double.MinValue, // Min Negative Normal - // -2.2250738585072014E-308, // Max Negative Normal - -2.2250738585072009E-308, // Min Negative Subnormal - -double.Epsilon, // Max Negative Subnormal (Negative Epsilon) - double.Epsilon, // Min Positive Subnormal (Positive Epsilon) - 2.2250738585072009E-308, // Max Positive Subnormal - // 2.2250738585072014E-308, // Min Positive Normal - double.MaxValue, // Max Positive Normal - }; - - foreach (string format in formats) - { - foreach (double testValue in specialTestValues) - { - yield return new object[] { format, testValue, 10_000_000 }; - } - - foreach (double testValue in normalTestValues) - { - yield return new object[] { format, testValue, 1_000_000 }; - } - - foreach (double testValue in edgeTestValues) - { - yield return new object[] { format, testValue, 100_000 }; - } - } - } - - [Benchmark] - [MemberData(nameof(ToStringWithFormat_TestData))] - public void ToStringWithFormat(string format, double number, int innerIterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _string = number.ToString(format); - } - } - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Enum.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Enum.cs deleted file mode 100644 index feb367ef3c6ad..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Enum.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Enum - { - private enum testEnum - { - Red = 1, - Blue = 2 - } - - [Benchmark] - public void Parse() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - Enum.Parse(typeof(testEnum), "Red"); Enum.Parse(typeof(testEnum), "Red"); Enum.Parse(typeof(testEnum), "Red"); - Enum.Parse(typeof(testEnum), "Red"); Enum.Parse(typeof(testEnum), "Red"); Enum.Parse(typeof(testEnum), "Red"); - Enum.Parse(typeof(testEnum), "Red"); Enum.Parse(typeof(testEnum), "Red"); Enum.Parse(typeof(testEnum), "Red"); - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Guid.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Guid.cs deleted file mode 100644 index eb05ee5fa3a17..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Guid.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Guid - { - [Benchmark] - public void NewGuid() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - Guid.NewGuid(); Guid.NewGuid(); Guid.NewGuid(); - Guid.NewGuid(); Guid.NewGuid(); Guid.NewGuid(); - Guid.NewGuid(); Guid.NewGuid(); Guid.NewGuid(); - } - } - - [Benchmark] - public void ctor_str() - { - const string guidStr = "a8a110d5-fc49-43c5-bf46-802db8f843ff"; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - new Guid(guidStr); new Guid(guidStr); new Guid(guidStr); - new Guid(guidStr); new Guid(guidStr); new Guid(guidStr); - new Guid(guidStr); new Guid(guidStr); new Guid(guidStr); - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.HashCode.netcoreapp.cs b/src/libraries/System.Runtime/tests/Performance/Perf.HashCode.netcoreapp.cs deleted file mode 100644 index d3def90ff7f31..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.HashCode.netcoreapp.cs +++ /dev/null @@ -1,209 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_HashCode - { - private static volatile int _valueStorage; - - // Prevents the jitter from eliminating code that - // we want to test. - - [MethodImpl(MethodImplOptions.NoInlining)] - private static void DontDiscard(int value) - { - _valueStorage = value; - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static int DontFold(int value) - { - return value + _valueStorage; - } - - [Benchmark] - public void Add() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 100; i++) - { - var hc = new HashCode(); - for (int j = 0; j < 100; j++) - { - hc.Add(i); hc.Add(i); hc.Add(i); - hc.Add(i); hc.Add(i); hc.Add(i); - hc.Add(i); hc.Add(i); hc.Add(i); - } - DontDiscard(hc.ToHashCode()); - } - } - } - } - - - [Benchmark] - public void Combine_1() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i))); - } - } - } - } - - - [Benchmark] - public void Combine_2() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i))); - } - } - } - } - - [Benchmark] - public void Combine_3() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i), - DontFold(i))); - } - } - } - } - - [Benchmark] - public void Combine_4() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i))); - } - } - } - } - - [Benchmark] - public void Combine_5() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i))); - } - } - } - } - - [Benchmark] - public void Combine_6() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i))); - } - } - } - } - - [Benchmark] - public void Combine_7() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i))); - } - } - } - } - - [Benchmark] - public void Combine_8() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 10000; i++) - { - DontDiscard(HashCode.Combine( - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i), - DontFold(i))); - } - } - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Int32.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Int32.cs deleted file mode 100644 index 66d1b30e3349b..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Int32.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_Int32 - { - private const int InnerCount = 500_000; - - private static string s_resultString; -#if netcoreapp - private static int s_resultInt32; -#endif - - public static object[][] Int32Values => new[] - { - new object[] { 0 }, - new object[] { -1 }, - new object[] { 1 }, - new object[] { -1283 }, - new object[] { 1283 }, - new object[] { -12837467 }, - new object[] { 12837467 }, - new object[] { -2147483648 }, - new object[] { 2147483647 }, - }; - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int32Values))] - public void ToString(int value) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultString = value.ToString(); - } - } - } - } - -#if netcoreapp - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int32Values))] - public void TryFormat(int value) - { - Span destination = new char[value.ToString().Length]; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - value.TryFormat(destination, out s_resultInt32); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int32Values))] - public void ParseInteger(int value) => Parse(value, null, NumberStyles.Integer); - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int32Values))] - public void ParseHex(int value) => Parse(value, "X", NumberStyles.HexNumber); - - private void Parse(int value, string format, NumberStyles styles) - { - ReadOnlySpan valueSpan = value.ToString(format); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultInt32 = int.Parse(valueSpan, styles); - } - } - } - } -#endif - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Int64.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Int64.cs deleted file mode 100644 index f4eee80cec949..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Int64.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_Int64 - { - private const int InnerCount = 500_000; - - private static string s_resultString; -#if netcoreapp - private static int s_resultInt32; - private static long s_resultInt64; -#endif - - public static object[][] Int64Values => new[] - { - new object[] { 214748364L }, - new object[] { 2L }, - new object[] { 21474836L }, - new object[] { 21474L }, - new object[] { 214L }, - new object[] { 2147L }, - new object[] { 214748L }, - new object[] { 21L }, - new object[] { 2147483L }, - new object[] { 922337203685477580L }, - new object[] { 92233720368547758L }, - new object[] { 9223372036854775L }, - new object[] { 922337203685477L }, - new object[] { 92233720368547L }, - new object[] { 9223372036854L }, - new object[] { 922337203685L }, - new object[] { 92233720368L }, - new object[] { -214748364L }, - new object[] { -2L }, - new object[] { -21474836L }, - new object[] { -21474L }, - new object[] { -214L }, - new object[] { -2147L }, - new object[] { -214748L }, - new object[] { -21L }, - new object[] { -2147483L }, - new object[] { -922337203685477580L }, - new object[] { -92233720368547758L }, - new object[] { -9223372036854775L }, - new object[] { -922337203685477L }, - new object[] { -92233720368547L }, - new object[] { -9223372036854L }, - new object[] { -922337203685L }, - new object[] { -92233720368L }, - new object[] { 0L }, - new object[] { -9223372036854775808L }, // min value - new object[] { 9223372036854775807L }, // max value - new object[] { -2147483648L }, // int32 min value - new object[] { 2147483647L }, // int32 max value - new object[] { -4294967295000000000L }, // -(uint.MaxValue * Billion) - new object[] { 4294967295000000000L }, // uint.MaxValue * Billion - new object[] { -4294967295000000001L }, // -(uint.MaxValue * Billion + 1) - new object[] { 4294967295000000001L }, // uint.MaxValue * Billion + 1 - }; - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int64Values))] - public void ToString(long value) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultString = value.ToString(); - } - } - } - } - -#if netcoreapp - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int64Values))] - public void TryFormat(long value) - { - Span destination = new char[value.ToString().Length]; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - value.TryFormat(destination, out s_resultInt32); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int64Values))] - public void ParseInteger(long value) => Parse(value, null, NumberStyles.Integer); - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(Int64Values))] - public void ParseHex(long value) => Parse(value, "X", NumberStyles.HexNumber); - - private void Parse(long value, string format, NumberStyles styles) - { - ReadOnlySpan valueSpan = value.ToString(format); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultInt64 = long.Parse(valueSpan, styles); - } - } - } - } -#endif - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.IntPtr.cs b/src/libraries/System.Runtime/tests/Performance/Perf.IntPtr.cs deleted file mode 100644 index 7fe6994137f9e..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.IntPtr.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_IntPtr - { - [Benchmark] - public void ctor_int32() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - new IntPtr(0); new IntPtr(0); new IntPtr(0); - new IntPtr(0); new IntPtr(0); new IntPtr(0); - new IntPtr(0); new IntPtr(0); new IntPtr(0); - } - } - - [Benchmark] - public void op_Equality_IntPtr_IntPtr() - { - bool res; - IntPtr ptr1 = new IntPtr(0); - IntPtr ptr2 = new IntPtr(0); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - res = ptr1 == ptr2; res = ptr1 == ptr2; res = ptr1 == ptr2; - res = ptr1 == ptr2; res = ptr1 == ptr2; res = ptr1 == ptr2; - res = ptr1 == ptr2; res = ptr1 == ptr2; res = ptr1 == ptr2; - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Object.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Object.cs deleted file mode 100644 index ce408cfa2632d..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Object.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Object - { - [Benchmark] - public void ctor() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - new object(); new object(); new object(); - new object(); new object(); new object(); - new object(); new object(); new object(); - } - } - - [Benchmark] - public void GetType_() - { - object obj = new object(); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - obj.GetType(); obj.GetType(); obj.GetType(); - obj.GetType(); obj.GetType(); obj.GetType(); - obj.GetType(); obj.GetType(); obj.GetType(); - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Single.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Single.cs deleted file mode 100644 index 30c72e36eef3c..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Single.cs +++ /dev/null @@ -1,198 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Globalization; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_Single - { - // NOTE: Consider duplicating any tests added here in Perf.Double.cs - - private volatile string _string; - private volatile bool _bool; - - // Reenable commented out test cases when https://github.com/xunit/xunit/issues/1822 is fixed. - [Benchmark] - [InlineData(float.NegativeInfinity, 10_000_000)] // Negative Infinity - [InlineData(float.MinValue, 100_000)] // Min Negative Normal - [InlineData(-3.14159265f, 1_000_000)] // Negative pi - [InlineData(-2.71828183f, 1_000_000)] // Negative e - [InlineData(-1.0f, 1_000_000)] // Negative One - // [InlineData(-1.17549435E-38f, 100_000)] // Max Negative Normal - [InlineData(-1.17549421E-38f, 100_000)] // Min Negative Subnormal - [InlineData(-float.Epsilon, 100_000)] // Max Negative Subnormal (Negative Epsilon) - [InlineData(-0.0f, 10_000_000)] // Negative Zero - [InlineData(float.NaN, 10_000_000)] // NaN - [InlineData(0.0f, 10_000_000)] // Positive Zero - [InlineData(float.Epsilon, 100_000)] // Min Positive Subnormal (Positive Epsilon) - [InlineData(1.17549421E-38f, 100_000)] // Max Positive Subnormal - // [InlineData(1.17549435E-38f, 100_000)] // Min Positive Normal - [InlineData(1.0f, 1_000_000)] // Positive One - [InlineData(2.71828183f, 1_000_000)] // Positive e - [InlineData(3.14159265f, 1_000_000)] // Positive pi - [InlineData(float.MaxValue, 100_000)] // Max Positive Normal - [InlineData(float.PositiveInfinity, 10_000_000)] // Positive Infinity - public void DefaultToString(float number, int innerIterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _string = number.ToString(); - } - } - } - } - - [Benchmark] - [InlineData("-∞", 10_000_000)] // Negative Infinity - [InlineData("-3.40282347E+38", 100_000)] // Min Negative Normal - [InlineData("-3.14159274", 1_000_000)] // Negative pi - [InlineData("-2.71828175", 1_000_000)] // Negative e - [InlineData("-1", 1_000_000)] // Negative One - // [InlineData("-1.17549435E-38", 100_000)] // Max Negative Normal - [InlineData("-1.17549421E-38", 100_000)] // Min Negative Subnormal - [InlineData("-1.401298E-45", 100_000)] // Max Negative Subnormal (Negative Epsilon) - [InlineData("-0.0", 10_000_000)] // Negative Zero - [InlineData("NaN", 10_000_000)] // NaN - [InlineData("0", 10_000_000)] // Positive Zero - [InlineData("1.401298E-45", 100_000)] // Min Positive Subnormal (Positive Epsilon) - [InlineData("1.17549421E-38", 100_000)] // Max Positive Subnormal - // [InlineData("1.17549435E-38", 100_000)] // Min Positive Normal - [InlineData("1", 1_000_000)] // Positive One - [InlineData("2.71828175", 1_000_000)] // Positive e - [InlineData("3.14159274", 1_000_000)] // Positive pi - [InlineData("3.40282347E+38", 100_000)] // Max Positive Normal - [InlineData("∞", 10_000_000)] // Positive Infinity - public void DefaultTryParse(string input, int innerIterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _bool = double.TryParse(input, out var result); - } - } - } - } - - [Benchmark] - [InlineData("zh", float.NegativeInfinity, 10_000_000)] // Negative Infinity - [InlineData("zh", float.MinValue, 100_000)] // Min Negative Normal - [InlineData("zh", -3.14159265f, 1_000_000)] // Negative pi - [InlineData("zh", -2.71828183f, 1_000_000)] // Negative e - [InlineData("zh", -1.0f, 1_000_000)] // Negative One - // [InlineData("zh", -1.17549435E-38f, 100_000)] // Max Negative Normal - [InlineData("zh", -1.17549421E-38f, 100_000)] // Min Negative Subnormal - [InlineData("zh", -float.Epsilon, 100_000)] // Max Negative Subnormal (Negative Epsilon) - [InlineData("zh", -0.0f, 10_000_000)] // Negative Zero - [InlineData("zh", float.NaN, 10_000_000)] // NaN - [InlineData("zh", 0.0f, 10_000_000)] // Positive Zero - [InlineData("zh", float.Epsilon, 100_000)] // Min Positive Subnormal (Positive Epsilon) - [InlineData("zh", 1.17549421E-38f, 100_000)] // Max Positive Subnormal - // [InlineData("zh", 1.17549435E-38f, 100_000)] // Min Positive Normal - [InlineData("zh", 1.0f, 1_000_000)] // Positive One - [InlineData("zh", 2.71828183f, 1_000_000)] // Positive e - [InlineData("zh", 3.14159265f, 1_000_000)] // Positive pi - [InlineData("zh", float.MaxValue, 100_000)] // Max Positive Normal - [InlineData("zh", float.PositiveInfinity, 10_000_000)] // Positive Infinity - public void ToStringWithCultureInfo(string cultureName, float number, int innerIterations) - { - CultureInfo cultureInfo = new CultureInfo(cultureName); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _string = number.ToString(cultureInfo); - } - } - } - } - - public static IEnumerable ToStringWithFormat_TestData() - { - string[] formats = - { - "R", // Roundtrip - "E", // Exponential - "F", // Fixed Point - }; - - float[] specialTestValues = // 10_000_000 iterations - { - float.NegativeInfinity, // Negative Infinity - -0.0f, // Negative Zero - float.NaN, // NaN - 0.0f, // Positive Zero - float.PositiveInfinity, // Positive Infinity - }; - - float[] normalTestValues = // 1_000_000 iterations - { - -3.14159265f, // Negative pi - -2.71828183f, // Negative e - -1.0f, // Negative One - 1.0f, // Positive One - 2.71828183f, // Positive e - 3.14159265f, // Positive pi - }; - - float[] edgeTestValues = // 100_000 iterations - { - float.MinValue, // Min Negative Normal - // -1.17549435E-38f, // Max Negative Normal - -1.17549421E-38f, // Min Negative Subnormal - -float.Epsilon, // Max Negative Subnormal (Negative Epsilon) - float.Epsilon, // Min Positive Subnormal (Positive Epsilon) - 1.17549421E-38f, // Max Positive Subnormal - // 1.17549435E-38f, // Min Positive Normal - float.MaxValue, // Max Positive Normal - }; - - foreach (string format in formats) - { - foreach (float testValue in specialTestValues) - { - yield return new object[] { format, testValue, 10_000_000 }; - } - - foreach (float testValue in normalTestValues) - { - yield return new object[] { format, testValue, 1_000_000 }; - } - - foreach (float testValue in edgeTestValues) - { - yield return new object[] { format, testValue, 100_000 }; - } - } - } - - [Benchmark] - [MemberData(nameof(ToStringWithFormat_TestData))] - public void ToStringWithFormat(string format, float number, int innerIterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - _string = number.ToString(format); - } - } - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.String.cs b/src/libraries/System.Runtime/tests/Performance/Perf.String.cs deleted file mode 100644 index 77f8d03901ec5..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.String.cs +++ /dev/null @@ -1,1007 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Globalization; -using System.Linq; -using System.Text; -using System.Collections.Generic; -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public partial class Perf_String - { - public static IEnumerable TestStringSizes() - { - yield return new object[] { 10 }; - yield return new object[] { 100 }; - yield return new object[] { 1000 }; - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void GetChars(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - testString.ToCharArray(); testString.ToCharArray(); testString.ToCharArray(); - testString.ToCharArray(); testString.ToCharArray(); testString.ToCharArray(); - testString.ToCharArray(); testString.ToCharArray(); testString.ToCharArray(); - } - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Concat_str_str(int size) - { - PerfUtils utils = new PerfUtils(); - string testString1 = utils.CreateString(size); - string testString2 = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - string.Concat(testString1, testString2); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Concat_str_str_str(int size) - { - PerfUtils utils = new PerfUtils(); - string testString1 = utils.CreateString(size); - string testString2 = utils.CreateString(size); - string testString3 = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - string.Concat(testString1, testString2, testString3); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Concat_str_str_str_str(int size) - { - PerfUtils utils = new PerfUtils(); - string testString1 = utils.CreateString(size); - string testString2 = utils.CreateString(size); - string testString3 = utils.CreateString(size); - string testString4 = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - string.Concat(testString1, testString2, testString3, testString4); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Contains(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - string subString = testString.Substring(testString.Length / 2, testString.Length / 4); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Contains(subString); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Equals(int size) - { - PerfUtils utils = new PerfUtils(); - string testString1 = utils.CreateString(size); - string testString2 = new string(testString1.ToCharArray()); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString1.Equals(testString2); - } - - [Benchmark] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(10)] - [InlineData(100)] - public void Format(int numberOfObjects) - { - PerfUtils utils = new PerfUtils(); - // Setup the format string and the list of objects to format - StringBuilder formatter = new StringBuilder(); - List objects = new List(); - for (int i = 0; i < numberOfObjects; i++) - { - formatter.Append("%s, "); - objects.Add(utils.CreateString(10)); - } - string format = formatter.ToString(); - string[] objectArr = objects.ToArray(); - - // Perform the actual formatting - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 5000; i++) - string.Format(format, objectArr); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void GetLength(int size) - { - PerfUtils utils = new PerfUtils(); - int result; - string testString = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - result = testString.Length; result = testString.Length; result = testString.Length; - result = testString.Length; result = testString.Length; result = testString.Length; - result = testString.Length; result = testString.Length; result = testString.Length; - } - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void op_Equality(int size) - { - PerfUtils utils = new PerfUtils(); - bool result; - string testString1 = utils.CreateString(size); - string testString2 = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - result = testString1 == testString2; result = testString1 == testString2; - result = testString1 == testString2; result = testString1 == testString2; - result = testString1 == testString2; result = testString1 == testString2; - } - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Replace(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - string existingValue = testString.Substring(testString.Length / 2, 1); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Replace(existingValue, "1"); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Split(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - string existingValue = testString.Substring(testString.Length / 2, 1); - string[] separator = new string[] { existingValue }; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Split(separator, StringSplitOptions.None); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void StartsWith(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - string subString = testString.Substring(0, testString.Length / 4); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.StartsWith(subString); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Substring_int(int size) - { - PerfUtils utils = new PerfUtils(); - int startIndex = size / 2; - string testString = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Substring(startIndex); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Substring_int_int(int size) - { - PerfUtils utils = new PerfUtils(); - int startIndex = size / 2; - int length = size / 4; - string testString = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Substring(startIndex, length); - } - - [Flags] - public enum ChangeCaseOptions - { - None = 0, - UniqueString = 0x1, - - MiddleTurkishI = 0x2, - MiddleDifferentCase = 0x4, - AllDifferentCase = 0x8, - } - - public static IEnumerable ChangeCaseMemberData() => - from size in new[] { 1, 10, 500 } - from culture in new[] { "en-US" } - from options in new[] - { - ChangeCaseOptions.None, - ChangeCaseOptions.MiddleTurkishI, - ChangeCaseOptions.MiddleDifferentCase, - ChangeCaseOptions.AllDifferentCase, - - ChangeCaseOptions.UniqueString, - ChangeCaseOptions.UniqueString | ChangeCaseOptions.MiddleTurkishI, - ChangeCaseOptions.UniqueString | ChangeCaseOptions.MiddleDifferentCase, - ChangeCaseOptions.UniqueString | ChangeCaseOptions.AllDifferentCase, - } - select new object[] { size, options, culture }; - - private static string CreateChangeCaseString(int size, ChangeCaseOptions options, bool upper) - { - Span chars = new char[size]; - - bool differentCase = (options & ChangeCaseOptions.AllDifferentCase) != 0; - chars.Fill(upper != differentCase ? 'S' : 's'); - - if ((options & ChangeCaseOptions.MiddleTurkishI) != 0) - { - chars[chars.Length / 2] = '\u0131'; - } - else if ((options & ChangeCaseOptions.MiddleDifferentCase) != 0) - { - char c = chars[chars.Length / 2]; - chars[chars.Length / 2] = char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c); - } - - return chars.ToString(); - } - - [Benchmark, MeasureGCAllocations] - [MemberData(nameof(ChangeCaseMemberData))] - public void ToLower(int size, ChangeCaseOptions options, string cultureName) - { - const int Iters = 10_000; - var strings = new string[Iters]; - var culture = new CultureInfo(cultureName); // Benchmark doesn't support CultureInfo as argument - string target = CreateChangeCaseString(size, options, upper: false); - - foreach (var iteration in Benchmark.Iterations) - { - for (int i = 0; i < strings.Length; i++) - { - strings[i] = (options & ChangeCaseOptions.UniqueString) != 0 ? string.Copy(target) : target; - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Iters; i++) - { - strings[i].ToLower(culture); - } - } - } - } - - [Benchmark, MeasureGCAllocations] - [MemberData(nameof(ChangeCaseMemberData))] - public void ToUpper(int size, ChangeCaseOptions options, string cultureName) - { - const int Iters = 10_000; - var strings = new string[Iters]; - var culture = new CultureInfo(cultureName); // Benchmark doesn't support CultureInfo as argument - string target = CreateChangeCaseString(size, options, upper: true); - - foreach (var iteration in Benchmark.Iterations) - { - for (int i = 0; i < strings.Length; i++) - { - strings[i] = (options & ChangeCaseOptions.UniqueString) != 0 ? string.Copy(target) : target; - } - - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Iters; i++) - { - strings[i].ToUpper(culture); - } - } - } - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Trim_WithWhitespace(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = " " + utils.CreateString(size) + " "; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Trim(); - } - - [Benchmark] - [MemberData(nameof(TestStringSizes))] - public void Trim_NothingToDo(int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Trim(); - } - - private static readonly string s_longString = "\n"; - private static readonly string s_tagName = " Permutations(params IEnumerable[] values) - { - IEnumerator[] enumerators = new IEnumerator[values.Length]; - try - { - while (true) - { - for (int i = 0; i < enumerators.Length; i++) - { - if (enumerators[i] != null) - { - if (enumerators[i].MoveNext()) - break; - - if (i == enumerators.Length - 1) - yield break; - } - - enumerators[i] = values[i].GetEnumerator(); - if (!enumerators[i].MoveNext()) - throw new ArgumentException("all arguments must have one or more elements", "values"); - } - - object[] result = new object[values.Length]; - - for (int i = 0; i < enumerators.Length; i++) - result[i] = enumerators[i].Current; - - yield return result; - } - } - finally - { - foreach (var enumerator in enumerators) - if (enumerator != null) - enumerator.Dispose(); - } - } - - private static readonly object[] s_caseStrings = new object[] - { - "", - " ", - "TeSt", - "TEST", - "test", - "I think Turkish i \u0131s TROUBL\u0130NG", - "dzsdzsDDZSDZSDZSddsz", - "a\u0300\u00C0A\u0300", - "Foo\u0400Bar", - "a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", - "\u4e33\u4e65 Testing... \u4EE8", - }; - - private static readonly object[] s_trimStrings = new object[] - { - "", - " ", - " ", - "Test", - " Test", - "Test ", - " Te st ", - "\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\t Te\t \tst \t\r\n\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005", - " \u0400Te \u0400st", - " a\u0300\u00C0", - " a \u0300 \u00C0 ", - " ddsz dszdsz \t dszdsz \t ", - }; - - private static readonly object[] s_getHashCodeStrings = new object[] - { - string.Empty, - " ", - "TeSt!", - "I think Turkish i \u0131s TROUBL\u0130NG", - "dzsdzsDDZSDZSDZSddsz", - "a\u0300\u00C0A\u0300A", - "Foo\u0400Bar!", - "a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", - "\u4e33\u4e65 Testing... \u4EE8", - }; - - private static readonly object[] s_trimCharArrays = new object[] - { - null, - new char[] { 'T' }, - new char[] { 'T', 'T', 'T', 'T', 'T' }, - new char[] { 'a' }, - new char[] { 'T', (char)192 }, - new char[] { ' ', (char)8197 }, - new char[] { "\u0400"[0] }, - new char[] { '1', 'a', ' ', '0', 'd', 'e', 's', 't', "\u0400"[0] }, - }; - - private static readonly object[] s_equalityStrings = new object[] - { - "a", - " ", - "TeSt!", - "I think Turkish i \u0131s TROUBL\u0130NG", - "dzsdzsDDZSDZSDZSddsz", - "a\u0300\u00C0A\u0300A", - "Foo\u0400Bar!", - "a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", - "\u4e33\u4e65 Testing... \u4EE8", - }; - - private static readonly string[][] s_comparePairs = new string[][] - { - new string[] { "The quick brown fox", "THE QUICK BROWN FOX" }, - new string[] { "The quick brown fox", "THE QUICK BROWN FOX J" }, - new string[] { "Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick BROWN f\u00f2x" }, - new string[] { "Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick BROWN f\u00f2x jumped" }, - new string[] { "A\u0300A\u0300A\u0300", "\u00e0\u00e0\u00e0" }, - new string[] { "A\u0300A\u0300A\u0300", "\u00e0\u00e0 Z" }, - }; - - private static readonly object[] s_compareOptions = new object[] - { - StringComparison.CurrentCultureIgnoreCase, - StringComparison.Ordinal, - StringComparison.OrdinalIgnoreCase, - }; - - private static readonly char[][] s_replaceCharPairs = new char[][] - { - new char[] {' ', 'T'}, - new char[] {'T', 'd'}, - new char[] {'d', 'a'}, - new char[] {'a', (char)192}, - new char[] {(char)192, (char)8197}, - new char[] {(char)8197, "\u0400"[0]}, - new char[] {"\u0400"[0], '\t'}, - new char[] {'\t', (char)768}, - new char[] {(char)768, ' '}, - }; - - private static readonly string[][] s_replaceStringPairs = new string[][] - { - new string[] {" ", "T"}, - new string[] {"T", "dd"}, - new string[] {"dd", "a"}, - new string[] {"a", "\u00C0"}, - new string[] {"\u00C0", "a\u0300"}, - new string[] {"a\u0300", "\u0400"}, - new string[] {"\u0400", "\u0300"}, - new string[] {"\u0300", "\u00A0\u2000"}, - new string[] {"\u00A0\u2000", " "}, - }; - - private static readonly object[] s_splitOptions = new object[] - { - StringSplitOptions.None, - StringSplitOptions.RemoveEmptyEntries, - }; - - public static IEnumerable CaseArgs => Permutations(s_caseStrings); - public static IEnumerable TrimArgs => Permutations(s_trimStrings); - public static IEnumerable TrimCharArrayArgs => Permutations(s_trimStrings, s_trimCharArrays); - public static IEnumerable EqualityArgs => Permutations(s_equalityStrings, s_equalityStrings); - public static IEnumerable GetHashCodeArgs => Permutations(s_getHashCodeStrings); - public static IEnumerable ReplaceCharArgs => Permutations(s_trimStrings, s_replaceCharPairs); - public static IEnumerable ReplaceStringArgs => Permutations(s_trimStrings, s_replaceStringPairs); - public static IEnumerable SplitArgs => Permutations(s_trimStrings, s_trimCharArrays, s_splitOptions); - public static IEnumerable CompareArgs => Permutations(s_comparePairs, s_compareOptions); - public static IEnumerable IndexOfArgs => Permutations(s_compareOptions); - - [Benchmark] - [MemberData(nameof(CaseArgs))] - public static void ToUpper(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.ToUpper(); - } - - [Benchmark] - [MemberData(nameof(CaseArgs))] - public static void ToUpperInvariant(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.ToUpperInvariant(); - } - - [Benchmark] - [MemberData(nameof(TrimArgs))] - public static void Trim(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Trim(); - } - - [Benchmark] - [MemberData(nameof(TrimCharArrayArgs))] - public static void Trim_CharArr(string s, char[] c) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Trim(c); - } - - [Benchmark] - [MemberData(nameof(TrimArgs))] - public static void TrimStart(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.TrimStart(); - } - - [Benchmark] - [MemberData(nameof(TrimCharArrayArgs))] - public static void TrimStart_CharArr(string s, char[] c) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.TrimStart(c); - } - - [Benchmark] - [MemberData(nameof(TrimArgs))] - public static void TrimEnd(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.TrimEnd(); - } - - [Benchmark] - [MemberData(nameof(TrimCharArrayArgs))] - public static void TrimEnd_CharArr(string s, char[] c) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.TrimEnd(c); - } - - [Benchmark] - [MemberData(nameof(EqualityArgs))] - public static bool Equality(string s1, string s2) - { - bool b = false; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - b |= (s1 == s2); - return b; - } - - public static IEnumerable FormatArgs1 => Permutations( - new object[] { "Testing {0}, {0:C}, {0:D5}, {0:E} - {0:F4}{0:G}{0:N} {0:X} !!" }, - new object[] { 8, 0 } - ); - - public static IEnumerable FormatArgs2 => Permutations( - new object[] { "Testing {0}, {0:C}, {0:E} - {0:F4}{0:G}{0:N} , !!" }, - new object[] { 0, -2, 3.14159, 11000000 } - ); - - public static IEnumerable FormatArgs3 => Permutations( - new object[] { "More testing: {0}" }, - new object[] { 0, -2, 3.14159, 11000000, "Foo", 'a', "Testing {0}, {0:C}, {0:D5}, {0:E} - {0:F4}{0:G}{0:N} {0:X} !!" } - ); - - [Benchmark] - [MemberData(nameof(FormatArgs1))] - [MemberData(nameof(FormatArgs2))] - [MemberData(nameof(FormatArgs3))] - public static void Format_OneArg(string s, object o) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - string.Format(s, o); - } - - [Benchmark] - public static void Format_MultipleArgs() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - string.Format("More testing: {0} {1} {2} {3} {4} {5}{6} {7}", '1', "Foo", "Foo", "Foo", "Foo", "Foo", "Foo", "Foo"); - } - - [Benchmark] - [MemberData(nameof(GetHashCodeArgs))] - public static void GetHashCode(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.GetHashCode(); - } - - [Benchmark] - public static int IndexerCheckBoundCheckHoist() - { - string s1 = "ddsz dszdsz \t dszdsz a\u0300\u00C0 \t Te st \u0400Te \u0400st\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\t Te\t \tst \t\r\n\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005"; - int counter = 0; - - int strLength = s1.Length; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < strLength; j++) - { - counter += s1[j]; - } - } - } - - return counter; - } - - [Benchmark] - public static int IndexerCheckLengthHoisting() - { - string s1 = "ddsz dszdsz \t dszdsz a\u0300\u00C0 \t Te st \u0400Te \u0400st\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\t Te\t \tst \t\r\n\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005"; - - int counter = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s1.Length; j++) - { - counter += s1[j]; - } - } - } - - return counter; - } - - [Benchmark] - public static int IndexerCheckPathLength() - { - string s1 = "ddsz dszdsz \t dszdsz a\u0300\u00C0 \t Te st \u0400Te \u0400st\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\t Te\t \tst \t\r\n\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005"; - - int counter = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int j = 0; j < s1.Length; j++) - { - counter += getStringCharNoInline(s1, j); - } - } - } - - return counter; - } - - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static char getStringCharNoInline(string str, int index) - { - return str[index]; - } - - [Benchmark] - [InlineData("", 0, " ")] - [InlineData(" ", 1, " ")] - [InlineData(" ", 1, "Test")] - [InlineData("Test", 2, " Test")] - [InlineData(" Test", 2, "Test ")] - [InlineData("Test ", 2, " Te st ")] - [InlineData(" Te st ", 3, "\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\t Te\t \tst \t\r\n\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005")] - [InlineData("\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\t Te\t \tst \t\r\n\u0020\u00A0\u2000\u2001\u2002\u2003\u2004\u2005", 3, " \u0400Te \u0400st")] - [InlineData(" \u0400Te \u0400st", 3, " a\u0300\u00C0")] - [InlineData(" a\u0300\u00C0", 3, " a \u0300 \u00C0 ")] - [InlineData(" a \u0300 \u00C0 ", 4, " ddsz dszdsz \t dszdsz \t ")] - [InlineData(" ddsz dszdsz \t dszdsz \t ", 5, "")] - public static void Insert(string s1, int i, string s2) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s1.Insert(i, s2); - } - - [Benchmark] - [InlineData(0)] - [InlineData(1)] - [InlineData(5)] - [InlineData(18)] - [InlineData(2142)] - public static void PadLeft(int n) - { - string s1 = "a"; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s1.PadLeft(n); - } - - [Benchmark] - [InlineData("a", 0)] - [InlineData(" ", 0)] - [InlineData(" ", 1)] - [InlineData("TeSt!", 0)] - [InlineData("TeSt!", 2)] - [InlineData("TeSt!", 3)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 0)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 18)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 22)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 0)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 7)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 10)] - [InlineData("a\u0300\u00C0A\u0300A", 0)] - [InlineData("a\u0300\u00C0A\u0300A", 3)] - [InlineData("a\u0300\u00C0A\u0300A", 4)] - [InlineData("Foo\u0400Bar!", 0)] - [InlineData("Foo\u0400Bar!", 3)] - [InlineData("Foo\u0400Bar!", 4)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 0)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 3)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 0)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 4)] - public static void Remove_Int(string s, int i) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Remove(i); - } - - [Benchmark] - [InlineData("a", 0, 0)] - [InlineData(" ", 0, 1)] - [InlineData(" ", 1, 0)] - [InlineData("TeSt!", 0, 2)] - [InlineData("TeSt!", 2, 1)] - [InlineData("TeSt!", 3, 0)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 0, 3)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 18, 3)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 22, 1)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 0, 8)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 7, 4)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 10, 1)] - [InlineData("a\u0300\u00C0A\u0300A", 0, 2)] - [InlineData("a\u0300\u00C0A\u0300A", 3, 1)] - [InlineData("a\u0300\u00C0A\u0300A", 4, 0)] - [InlineData("Foo\u0400Bar!", 0, 4)] - [InlineData("Foo\u0400Bar!", 3, 2)] - [InlineData("Foo\u0400Bar!", 4, 1)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 0, 2)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 3, 3)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 0, 3)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 4, 1)] - public static void Remove_IntInt(string s, int i1, int i2) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Remove(i1, i2); - } - - [Benchmark] - [MemberData(nameof(ReplaceCharArgs))] - public static void Replace_Char(string s, char[] chars) - { - char c1 = chars[0]; - char c2 = chars[1]; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Replace(c1, c2); - } - - [Benchmark] - [MemberData(nameof(ReplaceStringArgs))] - public static void Replace_String(string s0, string[] strings) - { - string s1 = strings[0]; - string s2 = strings[1]; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s0.Replace(s1, s2); - } - - [Benchmark] - [InlineData("The quick brown fox", "The quick brown fox")] - [InlineData("Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick brown f\u00f2x")] - [InlineData("Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick brown f\u00f2x jumped")] - [InlineData("a\u0300a\u0300a\u0300", "\u00e0\u00e0\u00e0")] - [InlineData("a\u0300a\u0300a\u0300", "\u00c0\u00c0\u00c0")] - public static void Compare_Culture_invariant(string s1, string s2) - { - CultureInfo cultureInfo = CultureInfo.InvariantCulture; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - cultureInfo.CompareInfo.Compare(s1, s2, CompareOptions.None); - } - - [Benchmark] - [InlineData("The quick brown fox", "The quick brown fox")] - [InlineData("Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick brown f\u00f2x")] - [InlineData("Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick brown f\u00f2x jumped")] - [InlineData("a\u0300a\u0300a\u0300", "\u00e0\u00e0\u00e0")] - [InlineData("a\u0300a\u0300a\u0300", "\u00c0\u00c0\u00c0")] - public static void Compare_Culture_en_us(string s1, string s2) - { - CultureInfo cultureInfo = new CultureInfo("en-us"); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - cultureInfo.CompareInfo.Compare(s1, s2, CompareOptions.None); - } - - [Benchmark] - [InlineData("The quick brown fox", "The quick brown fox")] - [InlineData("Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick brown f\u00f2x")] - [InlineData("Th\u00e9 quick brown f\u00f2x", "Th\u00e9 quick brown f\u00f2x jumped")] - [InlineData("a\u0300a\u0300a\u0300", "\u00e0\u00e0\u00e0")] - [InlineData("a\u0300a\u0300a\u0300", "\u00c0\u00c0\u00c0")] - public static void Compare_Culture_ja_jp(string s1, string s2) - { - CultureInfo cultureInfo = new CultureInfo("ja-jp"); - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - cultureInfo.CompareInfo.Compare(s1, s2, CompareOptions.None); - } - - [Benchmark] - [InlineData("", 0)] - [InlineData(" ", 0)] - [InlineData(" ", 1)] - [InlineData("TeSt", 0)] - [InlineData("TeSt", 2)] - [InlineData("TeSt", 3)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 0)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 18)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 22)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 0)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 7)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 10)] - [InlineData("a\u0300\u00C0A\u0300", 0)] - [InlineData("a\u0300\u00C0A\u0300", 3)] - [InlineData("a\u0300\u00C0A\u0300", 4)] - [InlineData("Foo\u0400Bar", 0)] - [InlineData("Foo\u0400Bar", 3)] - [InlineData("Foo\u0400Bar", 4)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 0)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 3)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 0)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 4)] - public static void Substring_Int(string s, int i) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Substring(i); - } - - [Benchmark] - [InlineData("", 0, 0)] - [InlineData(" ", 0, 1)] - [InlineData(" ", 1, 0)] - [InlineData("TeSt", 0, 2)] - [InlineData("TeSt", 2, 1)] - [InlineData("TeSt", 3, 0)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 0, 3)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 18, 3)] - [InlineData("I think Turkish i \u0131s TROUBL\u0130NG", 22, 1)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 0, 8)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 7, 4)] - [InlineData("dzsdzsDDZSDZSDZSddsz", 10, 1)] - [InlineData("a\u0300\u00C0A\u0300", 0, 2)] - [InlineData("a\u0300\u00C0A\u0300", 3, 1)] - [InlineData("a\u0300\u00C0A\u0300", 4, 0)] - [InlineData("Foo\u0400Bar", 0, 4)] - [InlineData("Foo\u0400Bar", 3, 2)] - [InlineData("Foo\u0400Bar", 4, 1)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 0, 2)] - [InlineData("a\u0020a\u00A0A\u2000a\u2001a\u2002A\u2003a\u2004a\u2005a", 3, 3)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 0, 3)] - [InlineData("\u4e33\u4e65 Testing... \u4EE8", 4, 1)] - public static void Substring_IntInt(string s, int i1, int i2) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Substring(i1, i2); - } - - [Benchmark] - [MemberData(nameof(SplitArgs))] - public static void Split(string s, char[] arr, StringSplitOptions options) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.Split(arr, options); - } - - [Benchmark] - [MemberData(nameof(CaseArgs))] - public static void ToLower(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.ToLower(); - } - - [Benchmark] - [MemberData(nameof(CaseArgs))] - public static void ToLowerInvariant(string s) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s.ToLowerInvariant(); - } - - [Benchmark] - [MemberData(nameof(CompareArgs))] - public static void Compare(string[] strings, StringComparison comparison) - { - string s1 = strings[0]; - string s2 = strings[1]; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - string.Compare(s1, s2, comparison); - } - - [Benchmark] - [MemberData(nameof(IndexOfArgs))] - public static void IndexOf(StringComparison options) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s_longString.IndexOf(s_tagName, options); - } - - [Benchmark] - [MemberData(nameof(IndexOfArgs))] - public static void LastIndexOf(StringComparison options) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - s_longString.LastIndexOf(s_tagName, options); - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.String.netcoreapp.cs b/src/libraries/System.Runtime/tests/Performance/Perf.String.netcoreapp.cs deleted file mode 100644 index ebd56b1080e3d..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.String.netcoreapp.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public partial class Perf_String - { - private static readonly object[] s_testStringSizes = new object[] - { - 10, 100, 1000 - }; - - public static IEnumerable ContainsStringComparisonArgs => Permutations(s_compareOptions, s_testStringSizes); - - [Benchmark] - [MemberData(nameof(ContainsStringComparisonArgs))] - public void Contains(StringComparison comparisonType, int size) - { - PerfUtils utils = new PerfUtils(); - string testString = utils.CreateString(size); - string subString = testString.Substring(testString.Length / 2, testString.Length / 4); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - testString.Contains(subString, comparisonType); - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.StringBuilder.cs b/src/libraries/System.Runtime/tests/Performance/Perf.StringBuilder.cs deleted file mode 100644 index 98a28ec89d209..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.StringBuilder.cs +++ /dev/null @@ -1,190 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text; -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_StringBuilder - { - [Benchmark] - public void ctor() - { - StringBuilder builder; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - builder = new StringBuilder(); builder = new StringBuilder(); builder = new StringBuilder(); - builder = new StringBuilder(); builder = new StringBuilder(); builder = new StringBuilder(); - builder = new StringBuilder(); builder = new StringBuilder(); builder = new StringBuilder(); - } - } - - [Benchmark] - [InlineData(100)] - [InlineData(1000)] - public void ctor_string(int length) - { - PerfUtils utils = new PerfUtils(); - string input = utils.CreateString(length); - StringBuilder builder; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - builder = new StringBuilder(input); builder = new StringBuilder(input); builder = new StringBuilder(input); - builder = new StringBuilder(input); builder = new StringBuilder(input); builder = new StringBuilder(input); - builder = new StringBuilder(input); builder = new StringBuilder(input); builder = new StringBuilder(input); - } - } - - [Benchmark] - [InlineData(0)] - [InlineData(200)] - public void Append(int length) - { - PerfUtils utils = new PerfUtils(); - foreach (var iteration in Benchmark.Iterations) - { - // Setup - Create a string of the specified length - string builtString = utils.CreateString(length); - StringBuilder empty = new StringBuilder(); - - // Actual perf testing - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - empty.Append(builtString); // Appends a string of length "length" to an increasingly large StringBuilder - } - } - - public const int NUM_ITERS_CONCAT = 1000; - public const int NUM_ITERS_APPEND = 1000; - public const int NUM_ITERS_TOSTRING = 1000; - - public static string s1 = "12345"; - public static string s2 = "1234567890"; - public static string s3 = "1234567890abcde"; - public static string s4 = "1234567890abcdefghij"; - public static string s5 = "1234567890abcdefghijklmno"; - public static string s6 = "1234567890abcdefghijklmnopqrst"; - public static string s7 = "1234567890abcdefghijklmnopqrstuvwxy"; - public static string s8 = "1234567890abcdefghijklmnopqrstuvwxyzABCD"; - public static string s9 = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHI"; - public static string s10 = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN"; - - [Benchmark] - public static void StringConcat() - { - foreach (var iteration in Benchmark.Iterations) - { - string str = ""; - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < NUM_ITERS_CONCAT; j++) - str += s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; - } - } - } - - [Benchmark] - public static void StringBuilderAppend() - { - foreach (var iteration in Benchmark.Iterations) - { - StringBuilder sb = new StringBuilder(); - - using (iteration.StartMeasurement()) - { - for (int j = 0; j < NUM_ITERS_APPEND; j++) - { - sb.Append(s1); - sb.Append(s2); - sb.Append(s3); - sb.Append(s4); - sb.Append(s5); - sb.Append(s6); - sb.Append(s7); - sb.Append(s8); - sb.Append(s9); - sb.Append(s10); - } - } - } - } - - [Benchmark] - public static void StringBuilderToString() - { - StringBuilder sb = new StringBuilder(); - - for (int j = 0; j < NUM_ITERS_TOSTRING; j++) - { - sb.Append(s1); - sb.Append(s2); - sb.Append(s3); - sb.Append(s4); - sb.Append(s5); - sb.Append(s6); - sb.Append(s7); - sb.Append(s8); - sb.Append(s9); - sb.Append(s10); - } - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - sb.ToString(); - } - } - } - - [Benchmark(InnerIterationCount = 1000)] - [InlineData(20)] - [InlineData(200)] - [InlineData(1000)] - public void AppendMemoryAsMemory(int length) - { - PerfUtils utils = new PerfUtils(); - foreach (var iteration in Benchmark.Iterations) - { - // Setup - Create a string of the specified length - string builtString = utils.CreateString(length); - ReadOnlyMemory memory = builtString.AsMemory(); - StringBuilder empty = new StringBuilder(); - - // Actual perf testing - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - empty.Append(memory); // Appends a string of length "length" to an increasingly large StringBuilder - } - } - - [Benchmark(InnerIterationCount = 1000)] - [InlineData(20)] - [InlineData(200)] - [InlineData(1000)] - public void AppendMemoryAsObject(int length) - { - PerfUtils utils = new PerfUtils(); - foreach (var iteration in Benchmark.Iterations) - { - // Setup - Create a string of the specified length - string builtString = utils.CreateString(length); - object memoryObject = builtString.AsMemory(); // deliberately uses object to force use of memory.ToString() for comparison to AppendAsReadOnlyMemory - StringBuilder empty = new StringBuilder(); - - // Actual perf testing - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - empty.Append(memoryObject); - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.TimeSpan.cs b/src/libraries/System.Runtime/tests/Performance/Perf.TimeSpan.cs deleted file mode 100644 index 9f040b9b4d991..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.TimeSpan.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_TimeSpan - { - [Benchmark] - public void ctor_int_int_int() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - new TimeSpan(7, 8, 10); new TimeSpan(7, 8, 10); new TimeSpan(7, 8, 10); - new TimeSpan(7, 8, 10); new TimeSpan(7, 8, 10); new TimeSpan(7, 8, 10); - new TimeSpan(7, 8, 10); new TimeSpan(7, 8, 10); new TimeSpan(7, 8, 10); - } - } - - [Benchmark] - public void FromSeconds() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) - { - TimeSpan.FromSeconds(50); TimeSpan.FromSeconds(50); TimeSpan.FromSeconds(50); - TimeSpan.FromSeconds(50); TimeSpan.FromSeconds(50); TimeSpan.FromSeconds(50); - TimeSpan.FromSeconds(50); TimeSpan.FromSeconds(50); TimeSpan.FromSeconds(50); - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.Type.cs b/src/libraries/System.Runtime/tests/Performance/Perf.Type.cs deleted file mode 100644 index eee302f040ff7..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.Type.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Type - { - [Benchmark] - public void GetTypeFromHandle() - { - RuntimeTypeHandle type1 = typeof(int).TypeHandle; - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 100000; i++) - { - Type.GetTypeFromHandle(type1); Type.GetTypeFromHandle(type1); Type.GetTypeFromHandle(type1); - Type.GetTypeFromHandle(type1); Type.GetTypeFromHandle(type1); Type.GetTypeFromHandle(type1); - Type.GetTypeFromHandle(type1); Type.GetTypeFromHandle(type1); Type.GetTypeFromHandle(type1); - } - } - - [Benchmark] - public void op_Equality() - { - bool result; - Type type1 = typeof(int); - Type type2 = typeof(string); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < 100000; i++) - { - result = type1 == type2; result = type1 == type2; result = type1 == type2; - result = type1 == type2; result = type1 == type2; result = type1 == type2; - result = type1 == type2; result = type1 == type2; result = type1 == type2; - } - } - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.UInt32.cs b/src/libraries/System.Runtime/tests/Performance/Perf.UInt32.cs deleted file mode 100644 index 882d2fb1cad9a..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.UInt32.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_UInt32 - { - private const int InnerCount = 500_000; - - private static string s_resultString; -#if netcoreapp - private static int s_resultInt32; - private static uint s_resultUInt32; -#endif - - public static object[][] UInt32Values => new[] - { - new object[] { 0u }, - new object[] { 1u }, - new object[] { 1283u }, - new object[] { 12837467u }, - new object[] { 4294967295u }, - }; - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(UInt32Values))] - public void ToString(uint value) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultString = value.ToString(); - } - } - } - } - -#if netcoreapp - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(UInt32Values))] - public void TryFormat(uint value) - { - Span destination = new char[value.ToString().Length]; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - value.TryFormat(destination, out s_resultInt32); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(UInt32Values))] - public void Parse(uint value) - { - ReadOnlySpan valueSpan = value.ToString(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultUInt32 = uint.Parse(valueSpan); - } - } - } - } -#endif - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/Perf.UInt64.cs b/src/libraries/System.Runtime/tests/Performance/Perf.UInt64.cs deleted file mode 100644 index 37a560461a8bd..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/Perf.UInt64.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Tests -{ - public class Perf_UInt64 - { - private const int InnerCount = 100_000; - - private static string s_resultString; -#if netcoreapp - private static int s_resultInt32; - private static ulong s_resultUInt64; -#endif - - public static object[][] UInt64Values => new[] - { - new object[] { 214748364LU }, - new object[] { 2LU }, - new object[] { 21474836LU }, - new object[] { 21474LU }, - new object[] { 214LU }, - new object[] { 2147LU }, - new object[] { 214748LU }, - new object[] { 21LU }, - new object[] { 2147483LU }, - new object[] { 922337203685477580LU }, - new object[] { 92233720368547758LU }, - new object[] { 9223372036854775LU }, - new object[] { 922337203685477LU }, - new object[] { 92233720368547LU }, - new object[] { 9223372036854LU }, - new object[] { 922337203685LU }, - new object[] { 92233720368LU }, - new object[] { 0LU }, // min value - new object[] { 18446744073709551615LU }, // max value - new object[] { 2147483647LU }, // int32 max value - new object[] { 9223372036854775807LU }, // int64 max value - new object[] { 1000000000000000000LU }, // quintillion - new object[] { 4294967295000000000LU }, // uint.MaxValue * Billion - new object[] { 4294967295000000001LU }, // uint.MaxValue * Billion + 1 - }; - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(UInt64Values))] - public void ToString(ulong value) - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultString = value.ToString(); - } - } - } - } - -#if netcoreapp - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(UInt64Values))] - public void TryFormat(ulong value) - { - Span destination = new char[value.ToString().Length]; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - value.TryFormat(destination, out s_resultInt32); - } - } - } - } - - [Benchmark(InnerIterationCount = InnerCount)] - [MemberData(nameof(UInt64Values))] - public void Parse(ulong value) - { - ReadOnlySpan valueSpan = value.ToString(); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerCount; i++) - { - s_resultUInt64 = ulong.Parse(valueSpan); - } - } - } - } -#endif - } -} diff --git a/src/libraries/System.Runtime/tests/Performance/System.Runtime.PerformanceTests.csproj b/src/libraries/System.Runtime/tests/Performance/System.Runtime.PerformanceTests.csproj deleted file mode 100644 index 2ad75af8fe013..0000000000000 --- a/src/libraries/System.Runtime/tests/Performance/System.Runtime.PerformanceTests.csproj +++ /dev/null @@ -1,42 +0,0 @@ - - - true - 1718 - {E9560F70-79F5-453A-B518-0292CFE4A6AD} - netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release - - - - - - - - - - - - - - - - - - - - - - - Common\System\PerfUtils.cs - - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - From 18961d5fc69660abbaf49918e6147c8699d9390a Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:49:01 +0100 Subject: [PATCH 25/45] remove System.Runtime.Extensions.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/f2dc86f5275d8ea4f76a54fb9a613ed60f8c3b1c --- .../System.Runtime.Extensions.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Environment.cs | 160 --------- .../tests/Performance/Perf.Path.cs | 326 ------------------ .../tests/Performance/Perf.Random.cs | 120 ------- .../tests/Performance/Perf.StreamWriter.cs | 115 ------ ...Runtime.Extensions.PerformanceTests.csproj | 23 -- .../tests/Performance/System/Perf.Convert.cs | 122 ------- 8 files changed, 883 deletions(-) delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Environment.cs delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Path.cs delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Random.cs delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/Perf.StreamWriter.cs delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/System.Runtime.Extensions.PerformanceTests.csproj delete mode 100644 src/libraries/System.Runtime.Extensions/tests/Performance/System/Perf.Convert.cs diff --git a/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln b/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln index e0de534cb4f11..fd4e6e880bf27 100644 --- a/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln +++ b/src/libraries/System.Runtime.Extensions/System.Runtime.Extensions.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyResolveTestApp", "t {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A} = {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Extensions.PerformanceTests", "tests\Performance\System.Runtime.Extensions.PerformanceTests.csproj", "{978FA427-F87B-46E2-B276-F5B727C50A01}" - ProjectSection(ProjectDependencies) = postProject - {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A} = {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "tests\TestApp\TestApp.csproj", "{24BCEC6B-B9D2-47BC-9D66-725BD6B526FA}" ProjectSection(ProjectDependencies) = postProject {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A} = {845D2B72-D8A4-42E5-9BE9-17639EC4FC1A} @@ -59,10 +54,6 @@ Global {E60AFAE8-2EA7-471C-9E24-52A99453B26B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {E60AFAE8-2EA7-471C-9E24-52A99453B26B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {E60AFAE8-2EA7-471C-9E24-52A99453B26B}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {978FA427-F87B-46E2-B276-F5B727C50A01}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {978FA427-F87B-46E2-B276-F5B727C50A01}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {978FA427-F87B-46E2-B276-F5B727C50A01}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {978FA427-F87B-46E2-B276-F5B727C50A01}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {24BCEC6B-B9D2-47BC-9D66-725BD6B526FA}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU {24BCEC6B-B9D2-47BC-9D66-725BD6B526FA}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {24BCEC6B-B9D2-47BC-9D66-725BD6B526FA}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU @@ -90,7 +81,6 @@ Global GlobalSection(NestedProjects) = preSolution {6C314C9B-3D28-4B05-9B4C-B57A00A9B3B9} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {E60AFAE8-2EA7-471C-9E24-52A99453B26B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {978FA427-F87B-46E2-B276-F5B727C50A01} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {24BCEC6B-B9D2-47BC-9D66-725BD6B526FA} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {C44B33E3-F89F-40B9-B353-D380C1524988} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {9F312D76-9AF1-4E90-B3B0-815A1EC6C346} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/Configurations.props b/src/libraries/System.Runtime.Extensions/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Environment.cs b/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Environment.cs deleted file mode 100644 index 5abaca814b8ae..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Environment.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections; -using Microsoft.Xunit.Performance; -using System.Runtime.InteropServices; -using Xunit; - -namespace System.Tests -{ - public class Perf_Environment - { - private volatile string str; - private volatile string[] arr; - private volatile IDictionary dict; - - [Benchmark(InnerIterationCount = 40000)] - public void GetEnvironmentVariable() - { - PerfUtils utils = new PerfUtils(); - string env = utils.CreateString(15); - try - { - // setup the environment variable so we can read it - Environment.SetEnvironmentVariable(env, "value"); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Environment.GetEnvironmentVariable(env); - } - - // read the valid environment variable for the test - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Environment.GetEnvironmentVariable(env); str = Environment.GetEnvironmentVariable(env); str = Environment.GetEnvironmentVariable(env); - str = Environment.GetEnvironmentVariable(env); str = Environment.GetEnvironmentVariable(env); str = Environment.GetEnvironmentVariable(env); - str = Environment.GetEnvironmentVariable(env); str = Environment.GetEnvironmentVariable(env); str = Environment.GetEnvironmentVariable(env); - } - } - finally - { - // clear the variable that we set - Environment.SetEnvironmentVariable(env, null); - } - } - - [Benchmark(InnerIterationCount = 40000)] - public void ExpandEnvironmentVariables() - { - PerfUtils utils = new PerfUtils(); - string env = utils.CreateString(15); - string inputEnv = "%" + env + "%"; - - try - { - // setup the environment variable so we can read it - Environment.SetEnvironmentVariable(env, "value"); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Environment.ExpandEnvironmentVariables(inputEnv); - } - - // read the valid environment variable - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Environment.ExpandEnvironmentVariables(inputEnv); str = Environment.ExpandEnvironmentVariables(inputEnv); - str = Environment.ExpandEnvironmentVariables(inputEnv); str = Environment.ExpandEnvironmentVariables(inputEnv); - str = Environment.ExpandEnvironmentVariables(inputEnv); str = Environment.ExpandEnvironmentVariables(inputEnv); - str = Environment.ExpandEnvironmentVariables(inputEnv); str = Environment.ExpandEnvironmentVariables(inputEnv); - str = Environment.ExpandEnvironmentVariables(inputEnv); str = Environment.ExpandEnvironmentVariables(inputEnv); - } - } - finally - { - // clear the variable that we set - Environment.SetEnvironmentVariable(env, null); - } - } - - [Benchmark(InnerIterationCount = 2000)] - public void GetEnvironmentVariables() - { - PerfUtils utils = new PerfUtils(); - string env = utils.CreateString(15); - try - { - // setup the environment variable so we can read it - Environment.SetEnvironmentVariable(env, "value"); - - // warmup - for (int i = 0; i < 100; i++) - { - dict = Environment.GetEnvironmentVariables(); - } - - // read the valid environment variable for the test - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - dict = Environment.GetEnvironmentVariables(); dict = Environment.GetEnvironmentVariables(); dict = Environment.GetEnvironmentVariables(); - dict = Environment.GetEnvironmentVariables(); dict = Environment.GetEnvironmentVariables(); dict = Environment.GetEnvironmentVariables(); - dict = Environment.GetEnvironmentVariables(); dict = Environment.GetEnvironmentVariables(); dict = Environment.GetEnvironmentVariables(); - } - } - finally - { - // clear the variable that we set - Environment.SetEnvironmentVariable(env, null); - } - } - - [Benchmark(InnerIterationCount = 20000)] - [InlineData(Environment.SpecialFolder.System, Environment.SpecialFolderOption.None)] - public void GetFolderPath(Environment.SpecialFolder folder, Environment.SpecialFolderOption option) - { - // warmup - for (int i = 0; i < 100; i++) - { - str = Environment.GetFolderPath(folder, option); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Environment.GetFolderPath(folder, option); str = Environment.GetFolderPath(folder, option); str = Environment.GetFolderPath(folder, option); - str = Environment.GetFolderPath(folder, option); str = Environment.GetFolderPath(folder, option); str = Environment.GetFolderPath(folder, option); - str = Environment.GetFolderPath(folder, option); str = Environment.GetFolderPath(folder, option); str = Environment.GetFolderPath(folder, option); - } - } - - [Benchmark(InnerIterationCount = 40000)] - public void GetLogicalDrives() - { - // warmup - for (int i = 0; i < 100; i++) - { - arr = Environment.GetLogicalDrives(); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - arr = Environment.GetLogicalDrives(); arr = Environment.GetLogicalDrives(); arr = Environment.GetLogicalDrives(); - arr = Environment.GetLogicalDrives(); arr = Environment.GetLogicalDrives(); arr = Environment.GetLogicalDrives(); - arr = Environment.GetLogicalDrives(); arr = Environment.GetLogicalDrives(); arr = Environment.GetLogicalDrives(); - } - } - } -} diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Path.cs b/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Path.cs deleted file mode 100644 index 466ddcf244dca..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Path.cs +++ /dev/null @@ -1,326 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.Tests -{ - public class Perf_Path - { - private volatile string str; - private volatile bool b; - - [Benchmark(InnerIterationCount = 150000)] - public void Combine() - { - PerfUtils utils = new PerfUtils(); - string testPath1 = utils.GetTestFilePath(); - string testPath2 = utils.CreateString(10); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.Combine(testPath1, testPath2); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.Combine(testPath1, testPath2); str = Path.Combine(testPath1, testPath2); str = Path.Combine(testPath1, testPath2); - str = Path.Combine(testPath1, testPath2); str = Path.Combine(testPath1, testPath2); str = Path.Combine(testPath1, testPath2); - str = Path.Combine(testPath1, testPath2); str = Path.Combine(testPath1, testPath2); str = Path.Combine(testPath1, testPath2); - } - } - - [Benchmark(InnerIterationCount = 100000)] - public void GetFileName() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetFileName(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetFileName(testPath); str = Path.GetFileName(testPath); str = Path.GetFileName(testPath); - str = Path.GetFileName(testPath); str = Path.GetFileName(testPath); str = Path.GetFileName(testPath); - str = Path.GetFileName(testPath); str = Path.GetFileName(testPath); str = Path.GetFileName(testPath); - } - } - - [Benchmark(InnerIterationCount = 80000)] - public void GetDirectoryName() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetDirectoryName(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetDirectoryName(testPath); str = Path.GetDirectoryName(testPath); str = Path.GetDirectoryName(testPath); - str = Path.GetDirectoryName(testPath); str = Path.GetDirectoryName(testPath); str = Path.GetDirectoryName(testPath); - str = Path.GetDirectoryName(testPath); str = Path.GetDirectoryName(testPath); str = Path.GetDirectoryName(testPath); - } - } - - [Benchmark(InnerIterationCount = 120000)] - public void ChangeExtension() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - string extension = utils.CreateString(4); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.ChangeExtension(testPath, extension); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.ChangeExtension(testPath, extension); str = Path.ChangeExtension(testPath, extension); str = Path.ChangeExtension(testPath, extension); - str = Path.ChangeExtension(testPath, extension); str = Path.ChangeExtension(testPath, extension); str = Path.ChangeExtension(testPath, extension); - str = Path.ChangeExtension(testPath, extension); str = Path.ChangeExtension(testPath, extension); str = Path.ChangeExtension(testPath, extension); - } - } - - [Benchmark(InnerIterationCount = 150000)] - public void GetExtension() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetExtension(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetExtension(testPath); str = Path.GetExtension(testPath); str = Path.GetExtension(testPath); - str = Path.GetExtension(testPath); str = Path.GetExtension(testPath); str = Path.GetExtension(testPath); - str = Path.GetExtension(testPath); str = Path.GetExtension(testPath); str = Path.GetExtension(testPath); - } - } - - [Benchmark(InnerIterationCount = 100000)] - public void GetFileNameWithoutExtension() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetFileNameWithoutExtension(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetFileNameWithoutExtension(testPath); str = Path.GetFileNameWithoutExtension(testPath); str = Path.GetFileNameWithoutExtension(testPath); - str = Path.GetFileNameWithoutExtension(testPath); str = Path.GetFileNameWithoutExtension(testPath); str = Path.GetFileNameWithoutExtension(testPath); - str = Path.GetFileNameWithoutExtension(testPath); str = Path.GetFileNameWithoutExtension(testPath); str = Path.GetFileNameWithoutExtension(testPath); - } - } - - [Benchmark(InnerIterationCount = 20000)] - public void GetFullPathForLegacyLength() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.CreateString(length: 200); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetFullPath(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - } - } - - [Benchmark(InnerIterationCount = 10000)] - public void GetFullPathForTypicalLongPath() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.CreateString(length: 500); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetFullPath(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - } - } - - [Benchmark(InnerIterationCount = 5000)] - public void GetFullPathForReallyLongPath() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.CreateString(length: 1000); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetFullPath(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); str = Path.GetFullPath(testPath); - } - } - - [Benchmark(InnerIterationCount = 100000)] - public void GetPathRoot() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetPathRoot(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetPathRoot(testPath); str = Path.GetPathRoot(testPath); str = Path.GetPathRoot(testPath); - str = Path.GetPathRoot(testPath); str = Path.GetPathRoot(testPath); str = Path.GetPathRoot(testPath); - str = Path.GetPathRoot(testPath); str = Path.GetPathRoot(testPath); str = Path.GetPathRoot(testPath); - } - } - - [Benchmark(InnerIterationCount = 150000)] - public void GetRandomFileName() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetRandomFileName(); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetRandomFileName(); str = Path.GetRandomFileName(); str = Path.GetRandomFileName(); - str = Path.GetRandomFileName(); str = Path.GetRandomFileName(); str = Path.GetRandomFileName(); - str = Path.GetRandomFileName(); str = Path.GetRandomFileName(); str = Path.GetRandomFileName(); - } - } - - [Benchmark(InnerIterationCount = 20000)] - public void GetTempPath() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - str = Path.GetTempPath(); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - str = Path.GetTempPath(); str = Path.GetTempPath(); str = Path.GetTempPath(); - str = Path.GetTempPath(); str = Path.GetTempPath(); str = Path.GetTempPath(); - str = Path.GetTempPath(); str = Path.GetTempPath(); str = Path.GetTempPath(); - } - } - - [Benchmark(InnerIterationCount = 200000)] - public void HasExtension() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - b = Path.HasExtension(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - b = Path.HasExtension(testPath); b = Path.HasExtension(testPath); b = Path.HasExtension(testPath); - b = Path.HasExtension(testPath); b = Path.HasExtension(testPath); b = Path.HasExtension(testPath); - b = Path.HasExtension(testPath); b = Path.HasExtension(testPath); b = Path.HasExtension(testPath); - } - } - - [Benchmark(InnerIterationCount = 250000)] - public void IsPathRooted() - { - PerfUtils utils = new PerfUtils(); - string testPath = utils.GetTestFilePath(); - - // warmup - for (int i = 0; i < 100; i++) - { - b = Path.IsPathRooted(testPath); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - b = Path.IsPathRooted(testPath); b = Path.IsPathRooted(testPath); b = Path.IsPathRooted(testPath); - b = Path.IsPathRooted(testPath); b = Path.IsPathRooted(testPath); b = Path.IsPathRooted(testPath); - b = Path.IsPathRooted(testPath); b = Path.IsPathRooted(testPath); b = Path.IsPathRooted(testPath); - } - } - } -} diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Random.cs b/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Random.cs deleted file mode 100644 index 173b16f222046..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.Random.cs +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Microsoft.Xunit.Performance; - -namespace System.Tests -{ - public class Perf_Random - { - private volatile Random random; - private volatile int integer; - private double d; - - [Benchmark(InnerIterationCount = 30000)] - public void ctor() - { - // warmup - for (int i = 0; i < 100; i++) - { - random = new Random(); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - random = new Random(); random = new Random(); random = new Random(); - random = new Random(); random = new Random(); random = new Random(); - random = new Random(); random = new Random(); random = new Random(); - } - } - - [Benchmark(InnerIterationCount = 1000000)] - public void Next_int() - { - Random rand = new Random(123456); - - // warmup - for (int i = 0; i < 100; i++) - { - integer = rand.Next(10000); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - integer = rand.Next(10000); integer = rand.Next(10000); integer = rand.Next(10000); - integer = rand.Next(10000); integer = rand.Next(10000); integer = rand.Next(10000); - integer = rand.Next(10000); integer = rand.Next(10000); integer = rand.Next(10000); - } - } - - [Benchmark(InnerIterationCount = 1000000)] - public void Next_int_int() - { - Random rand = new Random(123456); - - // warmup - for (int i = 0; i < 100; i++) - { - integer = rand.Next(100, 10000); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - integer = rand.Next(100, 10000); integer = rand.Next(100, 10000); integer = rand.Next(100, 10000); - integer = rand.Next(100, 10000); integer = rand.Next(100, 10000); integer = rand.Next(100, 10000); - integer = rand.Next(100, 10000); integer = rand.Next(100, 10000); integer = rand.Next(100, 10000); - } - } - - [Benchmark(InnerIterationCount = 5000)] - public void NextBytes() - { - Random rand = new Random(123456); - byte[] b1 = new byte[1000]; - - // warmup - for (int i = 0; i < 100; i++) - { - rand.NextBytes(b1); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - rand.NextBytes(b1); rand.NextBytes(b1); rand.NextBytes(b1); - rand.NextBytes(b1); rand.NextBytes(b1); rand.NextBytes(b1); - rand.NextBytes(b1); rand.NextBytes(b1); rand.NextBytes(b1); - } - } - - [Benchmark(InnerIterationCount = 1000000)] - public void NextDouble() - { - Random rand = new Random(123456); - - // warmup - for (int i = 0; i < 100; i++) - { - d = rand.NextDouble(); - } - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - d = rand.NextDouble(); d = rand.NextDouble(); d = rand.NextDouble(); - d = rand.NextDouble(); d = rand.NextDouble(); d = rand.NextDouble(); - d = rand.NextDouble(); d = rand.NextDouble(); d = rand.NextDouble(); - } - } - } -} diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.StreamWriter.cs b/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.StreamWriter.cs deleted file mode 100644 index 61fd7ad01d856..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/Perf.StreamWriter.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.IO; -using System.Text; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.IO.Tests -{ - public class Perf_StreamWriter - { - private const int MemoryStreamSize = 32768; - private const int TotalWriteCount = 16777216; // 2^24 - should yield around 300ms runs - private const int DefaultStreamWriterBufferSize = 1024; // Same as StreamWriter internal default - - [Benchmark] - [MemberData(nameof(WriteLengthMemberData))] - public void WriteCharArray(int writeLength) - { - char[] buffer = new string('a', writeLength).ToCharArray(); - int innerIterations = MemoryStreamSize / writeLength; - int outerIteration = TotalWriteCount / innerIterations; - using (var stream = new MemoryStream(MemoryStreamSize)) - { - using (var writer = new StreamWriter(stream, new UTF8Encoding(false, true), DefaultStreamWriterBufferSize, true)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < outerIteration; i++) - { - for (int j = 0; j < innerIterations; j++) - { - writer.Write(buffer); - } - writer.Flush(); - stream.Position = 0; - } - } - } - } - } - } - - [Benchmark] - [MemberData(nameof(WriteLengthMemberData))] - public void WritePartialCharArray(int writeLength) - { - char[] buffer = new string('a', writeLength + 10).ToCharArray(); - int innerIterations = MemoryStreamSize / writeLength; - int outerIteration = TotalWriteCount / innerIterations; - using (var stream = new MemoryStream(MemoryStreamSize)) - { - using (var writer = new StreamWriter(stream, new UTF8Encoding(false, true), DefaultStreamWriterBufferSize, true)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < outerIteration; i++) - { - for (int j = 0; j < innerIterations; j++) - { - writer.Write(buffer, 10, writeLength); - } - writer.Flush(); - stream.Position = 0; - } - } - } - } - } - } - - [Benchmark] - [MemberData(nameof(WriteLengthMemberData))] - public void WriteString(int writeLength) - { - string value = new string('a', writeLength); - int innerIterations = MemoryStreamSize / writeLength; - int outerIteration = TotalWriteCount / innerIterations; - using (var stream = new MemoryStream(MemoryStreamSize)) - { - using (var writer = new StreamWriter(stream, new UTF8Encoding(false, true), DefaultStreamWriterBufferSize, true)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < outerIteration; i++) - { - for (int j = 0; j < innerIterations; j++) - { - writer.Write(value); - } - writer.Flush(); - stream.Position = 0; - } - } - } - } - } - } - - public static IEnumerable WriteLengthMemberData() - { - yield return new object[] { 2 }; - yield return new object[] { 100 }; - } - } -} diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/System.Runtime.Extensions.PerformanceTests.csproj b/src/libraries/System.Runtime.Extensions/tests/Performance/System.Runtime.Extensions.PerformanceTests.csproj deleted file mode 100644 index 8737791ba4c49..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/System.Runtime.Extensions.PerformanceTests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - true - {978FA427-F87B-46E2-B276-F5B727C50A01} - netstandard-Debug;netstandard-Release - - - - - - - - Common\System\PerfUtils.cs - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.Extensions/tests/Performance/System/Perf.Convert.cs b/src/libraries/System.Runtime.Extensions/tests/Performance/System/Perf.Convert.cs deleted file mode 100644 index f9bdac896a9f6..0000000000000 --- a/src/libraries/System.Runtime.Extensions/tests/Performance/System/Perf.Convert.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System -{ - public class Perf_Convert - { - private byte[] InitializeBinaryDataCollection(int size) - { - var random = new Random(30000); - byte[] binaryData = new byte[size]; - random.NextBytes(binaryData); - - return binaryData; - } - - [Benchmark(InnerIterationCount = 20000000)] - public void GetTypeCode() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - object value = "Hello World!"; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - Convert.GetTypeCode(value); - } - } - } - } - - [Benchmark(InnerIterationCount = 6000000)] - public void ChangeType() - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - object value = 1000; - Type type = typeof(string); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - Convert.ChangeType(value, type); - } - } - } - } - - [Benchmark(InnerIterationCount = 100000)] - [InlineData(1024, Base64FormattingOptions.InsertLineBreaks)] - [InlineData(1024, Base64FormattingOptions.None)] - public void ToBase64CharArray(int binaryDataSize, Base64FormattingOptions formattingOptions) - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - byte[] binaryData = InitializeBinaryDataCollection(binaryDataSize); - int arraySize = Convert.ToBase64String(binaryData, formattingOptions).Length; - char[] base64CharArray = new char[arraySize]; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - Convert.ToBase64CharArray(binaryData, 0, binaryDataSize, base64CharArray, 0, formattingOptions); - } - } - } - } - - [Benchmark(InnerIterationCount = 100000)] - [InlineData(Base64FormattingOptions.InsertLineBreaks)] - [InlineData(Base64FormattingOptions.None)] - public void ToBase64String(Base64FormattingOptions formattingOptions) - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - byte[] binaryData = InitializeBinaryDataCollection(1024); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - Convert.ToBase64String(binaryData, formattingOptions); - } - } - } - } - - [Benchmark(InnerIterationCount = 400000)] - [InlineData("Fri, 27 Feb 2009 03:11:21 GMT")] - [InlineData("Thursday, February 26, 2009")] - [InlineData("February 26, 2009")] - [InlineData("12/12/1999 11:59:59 PM")] - [InlineData("12/12/1999")] - public void ToDateTime_String(string value) - { - int innerIterationCount = (int)Benchmark.InnerIterationCount; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterationCount; i++) - { - Convert.ToDateTime(value); - } - } - } - } - } -} From 9b545c9fadef9200ae77a8d4a84e734a2d6bde84 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:50:18 +0100 Subject: [PATCH 26/45] remove System.Runtime.Numerics.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/cfa2fe48c20629bc41e77daf911b9b4c9dfdc00c --- .../System.Runtime.Numerics.sln | 10 --- .../tests/Performance/Configurations.props | 8 -- .../tests/Performance/Perf.BigInteger.cs | 70 --------------- .../Performance/Perf.BigInteger.netcoreapp.cs | 85 ------------------- ...m.Runtime.Numerics.PerformanceTests.csproj | 20 ----- 5 files changed, 193 deletions(-) delete mode 100644 src/libraries/System.Runtime.Numerics/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.cs delete mode 100644 src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.netcoreapp.cs delete mode 100644 src/libraries/System.Runtime.Numerics/tests/Performance/System.Runtime.Numerics.PerformanceTests.csproj diff --git a/src/libraries/System.Runtime.Numerics/System.Runtime.Numerics.sln b/src/libraries/System.Runtime.Numerics/System.Runtime.Numerics.sln index 5d8176ba6682e..6aa634cd91c65 100644 --- a/src/libraries/System.Runtime.Numerics/System.Runtime.Numerics.sln +++ b/src/libraries/System.Runtime.Numerics/System.Runtime.Numerics.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Numerics.Tes {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B} = {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Numerics.PerformanceTests", "tests\Performance\System.Runtime.Numerics.PerformanceTests.csproj", "{3842BE38-1A99-41B2-81B5-186E64077B95}" - ProjectSection(ProjectDependencies) = postProject - {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B} = {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Numerics", "src\System.Runtime.Numerics.csproj", "{D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B}" ProjectSection(ProjectDependencies) = postProject {7D5CBF2F-337C-4AEB-B035-A17D33A9BC1F} = {7D5CBF2F-337C-4AEB-B035-A17D33A9BC1F} @@ -35,10 +30,6 @@ Global {28AE24F8-BEF4-4358-B612-ADD9D587C8E1}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {28AE24F8-BEF4-4358-B612-ADD9D587C8E1}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {28AE24F8-BEF4-4358-B612-ADD9D587C8E1}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {3842BE38-1A99-41B2-81B5-186E64077B95}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {3842BE38-1A99-41B2-81B5-186E64077B95}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {3842BE38-1A99-41B2-81B5-186E64077B95}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {3842BE38-1A99-41B2-81B5-186E64077B95}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {28AE24F8-BEF4-4358-B612-ADD9D587C8E1} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {3842BE38-1A99-41B2-81B5-186E64077B95} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {D2C99D27-0BEF-4319-ADB3-05CBEBA8F69B} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {7D5CBF2F-337C-4AEB-B035-A17D33A9BC1F} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Runtime.Numerics/tests/Performance/Configurations.props b/src/libraries/System.Runtime.Numerics/tests/Performance/Configurations.props deleted file mode 100644 index f5d3d45ffbf44..0000000000000 --- a/src/libraries/System.Runtime.Numerics/tests/Performance/Configurations.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - netcoreapp; - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.cs b/src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.cs deleted file mode 100644 index 5be095492a822..0000000000000 --- a/src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Numerics.Tests -{ - public partial class Perf_BigInteger - { - public static IEnumerable NumberStrings() - { - yield return new object[] { "123" }; - yield return new object[] { int.MinValue.ToString() }; - yield return new object[] { string.Concat(Enumerable.Repeat("1234567890", 20)) }; - } - - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void Ctor_ByteArray(string numberString) - { - byte[] input = BigInteger.Parse(numberString).ToByteArray(); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 1000000; i++) - { - var bi = new BigInteger(input); - } - } - } - } - - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void ToByteArray(string numberString) - { - BigInteger bi = BigInteger.Parse(numberString); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 1000000; i++) - { - bi.ToByteArray(); - } - } - } - } - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void Parse(string numberString) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 100000; i++) - { - BigInteger.Parse(numberString); - } - } - } - } - } -} diff --git a/src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.netcoreapp.cs b/src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.netcoreapp.cs deleted file mode 100644 index de19886705582..0000000000000 --- a/src/libraries/System.Runtime.Numerics/tests/Performance/Perf.BigInteger.netcoreapp.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Numerics.Tests -{ - public partial class Perf_BigInteger - { - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void Ctor_ByteSpan(string numberString) - { - Span input = BigInteger.Parse(numberString).ToByteArray(); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 1000000; i++) - { - var bi = new BigInteger(input); - } - } - } - } - - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void Ctor_ByteSpan_BigEndian(string numberString) - { - Span input = BigInteger.Parse(numberString).ToByteArray(isBigEndian: true); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 1000000; i++) - { - var bi = new BigInteger(input, isBigEndian: true); - } - } - } - } - - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void TryWriteBytes(string numberString) - { - BigInteger bi = BigInteger.Parse(numberString); - Span destination = new byte[bi.GetByteCount()]; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 1000000; i++) - { - bi.TryWriteBytes(destination, out int bytesWritten); - } - } - } - } - - [Benchmark] - [MemberData(nameof(NumberStrings))] - public void TryWriteBytes_BigEndian(string numberString) - { - BigInteger bi = BigInteger.Parse(numberString); - Span destination = new byte[bi.GetByteCount()]; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < 1000000; i++) - { - bi.TryWriteBytes(destination, out int bytesWritten, isBigEndian: true); - } - } - } - } - } -} diff --git a/src/libraries/System.Runtime.Numerics/tests/Performance/System.Runtime.Numerics.PerformanceTests.csproj b/src/libraries/System.Runtime.Numerics/tests/Performance/System.Runtime.Numerics.PerformanceTests.csproj deleted file mode 100644 index 5bd1106883f24..0000000000000 --- a/src/libraries/System.Runtime.Numerics/tests/Performance/System.Runtime.Numerics.PerformanceTests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - {3842BE38-1A99-41B2-81B5-186E64077B95} - true - netcoreapp-Debug;netcoreapp-Release;netstandard-Debug;netstandard-Release - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 9fe936e42ac1b05b0f2180dddcbabc3816f70aab Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:51:49 +0100 Subject: [PATCH 27/45] remove System.Runtime.Serialization.Json.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/f98b01f3c61cb94a403fa4ac98a039a62646c245 --- .../System.Runtime.Serialization.Json.sln | 10 --- .../tests/Performance/Configurations.props | 7 -- .../tests/Performance/DcjsPerformanceTest.cs | 80 ------------------ .../Performance/JsonNetPerformanceTest.cs | 84 ------------------- ...Serialization.Json.PerformanceTests.csproj | 24 ------ 5 files changed, 205 deletions(-) delete mode 100644 src/libraries/System.Runtime.Serialization.Json/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Runtime.Serialization.Json/tests/Performance/DcjsPerformanceTest.cs delete mode 100644 src/libraries/System.Runtime.Serialization.Json/tests/Performance/JsonNetPerformanceTest.cs delete mode 100644 src/libraries/System.Runtime.Serialization.Json/tests/Performance/System.Runtime.Serialization.Json.PerformanceTests.csproj diff --git a/src/libraries/System.Runtime.Serialization.Json/System.Runtime.Serialization.Json.sln b/src/libraries/System.Runtime.Serialization.Json/System.Runtime.Serialization.Json.sln index c699384466aa7..00aeb429f7775 100644 --- a/src/libraries/System.Runtime.Serialization.Json/System.Runtime.Serialization.Json.sln +++ b/src/libraries/System.Runtime.Serialization.Json/System.Runtime.Serialization.Json.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serializatio {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} = {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Json.PerformanceTests", "tests\Performance\System.Runtime.Serialization.Json.PerformanceTests.csproj", "{F6836E5C-BFA0-4E92-ADEE-87E797D7C90C}" - ProjectSection(ProjectDependencies) = postProject - {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} = {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Json.ReflectionOnly.Tests", "tests\ReflectionOnly\System.Runtime.Serialization.Json.ReflectionOnly.Tests.csproj", "{C99A835E-46F3-4C05-AD34-7DD84FB7466B}" ProjectSection(ProjectDependencies) = postProject {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} = {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} @@ -40,10 +35,6 @@ Global {173F6978-B961-4D1C-84E4-06468772D019}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {173F6978-B961-4D1C-84E4-06468772D019}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {173F6978-B961-4D1C-84E4-06468772D019}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {F6836E5C-BFA0-4E92-ADEE-87E797D7C90C}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {F6836E5C-BFA0-4E92-ADEE-87E797D7C90C}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {F6836E5C-BFA0-4E92-ADEE-87E797D7C90C}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {F6836E5C-BFA0-4E92-ADEE-87E797D7C90C}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {C99A835E-46F3-4C05-AD34-7DD84FB7466B}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU {C99A835E-46F3-4C05-AD34-7DD84FB7466B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {C99A835E-46F3-4C05-AD34-7DD84FB7466B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU @@ -62,7 +53,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {173F6978-B961-4D1C-84E4-06468772D019} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {F6836E5C-BFA0-4E92-ADEE-87E797D7C90C} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {C99A835E-46F3-4C05-AD34-7DD84FB7466B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {AAFFA8F4-BDA9-4107-A650-9014F64EDAE9} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {5119E88F-FA73-4FC6-A327-DD7C77E746BC} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} diff --git a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/Configurations.props b/src/libraries/System.Runtime.Serialization.Json/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/DcjsPerformanceTest.cs b/src/libraries/System.Runtime.Serialization.Json/tests/Performance/DcjsPerformanceTest.cs deleted file mode 100644 index 5af54ea0823ac..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/DcjsPerformanceTest.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Runtime.Serialization.Json.Tests.Performance -{ - #region DCJS performance tests - - public class DcjsPerformanceTest - { - public static IEnumerable SerializeMemberData() - { - return PerformanceTestCommon.PerformanceMemberData(); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberData))] - public void DcjsSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunSerializationPerformanceTest(numberOfRuns, testType, testSize, DcjsSerializerFactory.GetInstance()); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberData))] - public void DcjsDeSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunDeserializationPerformanceTest(numberOfRuns, testType, testSize, DcjsSerializerFactory.GetInstance()); - } - } - - #endregion - - #region DCJS serializer wrapper - - internal class DcjsSerializerFactory : ISerializerFactory - { - private static readonly DcjsSerializerFactory s_instance = new DcjsSerializerFactory(); - public static DcjsSerializerFactory GetInstance() - { - return s_instance; - } - - public IPerfTestSerializer GetSerializer() - { - return new DcjsSerializer(); - } - } - - internal class DcjsSerializer : IPerfTestSerializer - { - private DataContractJsonSerializer _serializer; - - public void Deserialize(Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - _serializer.ReadObject(stream); - } - - public void Init(object obj) - { - _serializer = new DataContractJsonSerializer(obj.GetType()); - } - - public void Serialize(object obj, Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - _serializer.WriteObject(stream, obj); - } - } - - #endregion -} diff --git a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/JsonNetPerformanceTest.cs b/src/libraries/System.Runtime.Serialization.Json/tests/Performance/JsonNetPerformanceTest.cs deleted file mode 100644 index 40a0a40e6ca37..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/JsonNetPerformanceTest.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using Microsoft.Xunit.Performance; -using Newtonsoft.Json; -using Xunit; - -namespace System.Runtime.Serialization.Json.Tests.Performance -{ - #region Json.NET performance tests - - public class JsonNetPerformanceTest - { - public static IEnumerable SerializeMemberDataJsonNet() - { - return PerformanceTestCommon.PerformanceMemberData(); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberDataJsonNet))] - public void JsonNetSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunSerializationPerformanceTest(numberOfRuns, testType, testSize, JsonNetSerializerFactory.GetInstance()); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberDataJsonNet))] - public void JsonNetDeSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunDeserializationPerformanceTest(numberOfRuns, testType, testSize, JsonNetSerializerFactory.GetInstance()); - } - } - - #endregion - - #region Json.Net serializer wrapper - - internal class JsonNetSerializerFactory : ISerializerFactory - { - private static readonly JsonNetSerializerFactory s_instance = new JsonNetSerializerFactory(); - public static JsonNetSerializerFactory GetInstance() - { - return s_instance; - } - - public IPerfTestSerializer GetSerializer() - { - return new JsonNetSerializer(); - } - } - - internal class JsonNetSerializer : IPerfTestSerializer - { - private JsonSerializer _serializer; - - public void Deserialize(Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - JsonReader reader = new JsonTextReader(new StreamReader(stream)); - _serializer.Deserialize(reader); - } - - public void Init(object obj) - { - _serializer = new JsonSerializer(); - } - - public void Serialize(object obj, Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - var writer = new StreamWriter(stream); - _serializer.Serialize(writer, obj); - writer.Flush(); - } - } - - #endregion -} diff --git a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/System.Runtime.Serialization.Json.PerformanceTests.csproj b/src/libraries/System.Runtime.Serialization.Json/tests/Performance/System.Runtime.Serialization.Json.PerformanceTests.csproj deleted file mode 100644 index 902211494c40f..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Json/tests/Performance/System.Runtime.Serialization.Json.PerformanceTests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - {F6836E5C-BFA0-4E92-ADEE-87E797D7C90C} - netstandard-Debug;netstandard-Release - - - - - - - - - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From e2529ae9c518fe02d03a80d585b0eeab160e2770 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:53:25 +0100 Subject: [PATCH 28/45] remove System.Runtime.Serialization.Xml.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/6ce211e02f219769eb94238adde788374db13a0e --- .../System.Runtime.Serialization.Xml.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/DcsPerformanceTest.cs | 80 ---- .../Performance/PerformanceTestsCommon.cs | 346 ------------------ ....Serialization.Xml.PerformanceTests.csproj | 24 -- .../Performance/XmlUTF8TextReaderTests.cs | 145 -------- 6 files changed, 612 deletions(-) delete mode 100644 src/libraries/System.Runtime.Serialization.Xml/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Runtime.Serialization.Xml/tests/Performance/DcsPerformanceTest.cs delete mode 100644 src/libraries/System.Runtime.Serialization.Xml/tests/Performance/PerformanceTestsCommon.cs delete mode 100644 src/libraries/System.Runtime.Serialization.Xml/tests/Performance/System.Runtime.Serialization.Xml.PerformanceTests.csproj delete mode 100644 src/libraries/System.Runtime.Serialization.Xml/tests/Performance/XmlUTF8TextReaderTests.cs diff --git a/src/libraries/System.Runtime.Serialization.Xml/System.Runtime.Serialization.Xml.sln b/src/libraries/System.Runtime.Serialization.Xml/System.Runtime.Serialization.Xml.sln index 92d0ad40a540d..812795396499e 100644 --- a/src/libraries/System.Runtime.Serialization.Xml/System.Runtime.Serialization.Xml.sln +++ b/src/libraries/System.Runtime.Serialization.Xml/System.Runtime.Serialization.Xml.sln @@ -12,11 +12,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serializatio {9D747A18-C8FD-4D7A-8913-4ED7911683B4} = {9D747A18-C8FD-4D7A-8913-4ED7911683B4} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Xml.PerformanceTests", "tests\Performance\System.Runtime.Serialization.Xml.PerformanceTests.csproj", "{122A5432-C5B7-4293-AFDA-B24F4D54FDEF}" - ProjectSection(ProjectDependencies) = postProject - {9D747A18-C8FD-4D7A-8913-4ED7911683B4} = {9D747A18-C8FD-4D7A-8913-4ED7911683B4} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Serialization.Xml.ReflectionOnly.Tests", "tests\ReflectionOnly\System.Runtime.Serialization.Xml.ReflectionOnly.Tests.csproj", "{38889701-0af4-48b3-999c-e99d639c61b6}" ProjectSection(ProjectDependencies) = postProject {9D747A18-C8FD-4D7A-8913-4ED7911683B4} = {9D747A18-C8FD-4D7A-8913-4ED7911683B4} @@ -49,10 +44,6 @@ Global {D3AD82FC-051D-4121-8E48-B13CE8024776}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {D3AD82FC-051D-4121-8E48-B13CE8024776}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {D3AD82FC-051D-4121-8E48-B13CE8024776}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {122A5432-C5B7-4293-AFDA-B24F4D54FDEF}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {122A5432-C5B7-4293-AFDA-B24F4D54FDEF}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {122A5432-C5B7-4293-AFDA-B24F4D54FDEF}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {122A5432-C5B7-4293-AFDA-B24F4D54FDEF}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {38889701-0af4-48b3-999c-e99d639c61b6}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU {38889701-0af4-48b3-999c-e99d639c61b6}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {38889701-0af4-48b3-999c-e99d639c61b6}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU @@ -72,7 +63,6 @@ Global GlobalSection(NestedProjects) = preSolution {30CAB353-089E-4294-B23B-F2DD1D945654} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {D3AD82FC-051D-4121-8E48-B13CE8024776} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {122A5432-C5B7-4293-AFDA-B24F4D54FDEF} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {38889701-0af4-48b3-999c-e99d639c61b6} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {9D747A18-C8FD-4D7A-8913-4ED7911683B4} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {025743B4-6E1E-4602-BE7F-1E479CC8EEBE} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/Configurations.props b/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/DcsPerformanceTest.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/DcsPerformanceTest.cs deleted file mode 100644 index 44a4d0884c0a4..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/DcsPerformanceTest.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Runtime.Serialization.Xml.Tests.Performance -{ - #region DCS performance tests - - public class DcsPerformanceTest - { - public static IEnumerable SerializeMemberData() - { - return PerformanceTestCommon.PerformanceMemberData(); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberData))] - public void DcsSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunSerializationPerformanceTest(numberOfRuns, testType, testSize, DcsSerializerFactory.GetInstance()); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberData))] - public void DcsDeSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunDeserializationPerformanceTest(numberOfRuns, testType, testSize, DcsSerializerFactory.GetInstance()); - } - } - - #endregion - - #region DCS serializer wrapper - - internal class DcsSerializerFactory : ISerializerFactory - { - private static readonly DcsSerializerFactory s_instance = new DcsSerializerFactory(); - public static DcsSerializerFactory GetInstance() - { - return s_instance; - } - - public IPerfTestSerializer GetSerializer() - { - return new DcsSerializer(); - } - } - - internal class DcsSerializer : IPerfTestSerializer - { - private DataContractSerializer _serializer; - - public void Deserialize(Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - _serializer.ReadObject(stream); - } - - public void Init(object obj) - { - _serializer = new DataContractSerializer(obj.GetType()); - } - - public void Serialize(object obj, Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - _serializer.WriteObject(stream, obj); - } - } - - #endregion -} diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/PerformanceTestsCommon.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/PerformanceTestsCommon.cs deleted file mode 100644 index 5a8fbf3034852..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/PerformanceTestsCommon.cs +++ /dev/null @@ -1,346 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xunit.Performance; -using System.Xml; -using SerializationTypes; - -namespace System.Runtime.Serialization -{ - #region Performance tests configuration types - - public enum TestType - { - SimpleType, - ISerializable, - Dictionary, - ListOfInt, - String, - ByteArray, - XmlElement, - DateTimeArray, - ArrayOfSimpleType, - ListOfSimpleType, - DictionaryOfSimpleType, - SimpleStructWithProperties, - SimpleTypeWithFields - } - - public interface IPerfTestSerializer - { - void Init(object obj); - void Serialize(object obj, Stream s); - void Deserialize(Stream s); - } - - public interface ISerializerFactory - { - IPerfTestSerializer GetSerializer(); - } - - public class PerfTestConfig - { - public readonly int NumberOfRuns; - public readonly TestType PerfTestType; - public readonly int TestSize; - - public PerfTestConfig() { } - - public PerfTestConfig(int numOfRuns, TestType testType, int testSize) - { - NumberOfRuns = numOfRuns; - PerfTestType = testType; - TestSize = testSize; - } - - public object[] ToObjectArray() - { - return new object[] { NumberOfRuns, PerfTestType, TestSize }; - } - } - - #endregion - - public class PerformanceTestCommon - { - #region Performance test configuration - - public static IEnumerable PerformanceTestConfigurations() - { - yield return new PerfTestConfig(100, TestType.ByteArray, 1024); - yield return new PerfTestConfig(5, TestType.ByteArray, 1024 * 1024); - yield return new PerfTestConfig(10000, TestType.String, 128); - yield return new PerfTestConfig(10000, TestType.String, 1024); - yield return new PerfTestConfig(1000, TestType.ListOfInt, 128); - yield return new PerfTestConfig(100, TestType.ListOfInt, 1024); - yield return new PerfTestConfig(1, TestType.ListOfInt, 1024 * 1024); - yield return new PerfTestConfig(1000, TestType.Dictionary, 128); - yield return new PerfTestConfig(100, TestType.Dictionary, 1024); - yield return new PerfTestConfig(10, TestType.SimpleType, 1); - yield return new PerfTestConfig(1, TestType.SimpleType, 15); - yield return new PerfTestConfig(1, TestType.SimpleTypeWithFields, 15); - yield return new PerfTestConfig(10000, TestType.SimpleStructWithProperties, 1); - yield return new PerfTestConfig(10000, TestType.ISerializable, -1); - yield return new PerfTestConfig(10000, TestType.XmlElement, -1); - yield return new PerfTestConfig(100, TestType.DateTimeArray, 1024); - yield return new PerfTestConfig(1000, TestType.ArrayOfSimpleType, 128); - yield return new PerfTestConfig(100, TestType.ArrayOfSimpleType, 1024); - yield return new PerfTestConfig(1000, TestType.ListOfSimpleType, 128); - yield return new PerfTestConfig(100, TestType.ListOfSimpleType, 1024); - yield return new PerfTestConfig(1000, TestType.DictionaryOfSimpleType, 128); - yield return new PerfTestConfig(100, TestType.DictionaryOfSimpleType, 1024); - } - - public static IEnumerable PerformanceMemberData() - { - foreach (PerfTestConfig config in PerformanceTestConfigurations()) - { - yield return config.ToObjectArray(); - } - } - - #endregion - - #region Methods to create object for serialization tests - - public static SimpleTypeWihtMoreProperties CreateSimpleTypeWihtMoreProperties(int height, int parentId, int currentId, int collectionSize, int childListSize) - { - int index = parentId * childListSize + (currentId + 1); - var obj = new SimpleTypeWihtMoreProperties() - { - IntProperty = index, - StringProperty = index + " string value", - EnumProperty = (MyEnum)(index % (Enum.GetNames(typeof(MyEnum)).Length)), - CollectionProperty = new List(collectionSize), - SimpleTypeList = new List(childListSize) - }; - for (int i = 0; i < collectionSize; ++i) - { - obj.CollectionProperty.Add(index + "." + i); - } - if (height > 1) - { - for (int i = 0; i < childListSize; ++i) - { - obj.SimpleTypeList.Add(CreateSimpleTypeWihtMoreProperties(height - 1, index, i, collectionSize, childListSize)); - } - } - return obj; - } - - public static SimpleTypeWithMoreFields CreateSimpleTypeWithFields(int height, int parentId, int currentId, int collectionSize, int childListSize) - { - int index = parentId * childListSize + (currentId + 1); - var obj = new SimpleTypeWithMoreFields() - { - IntField = index, - StringField = index + " string value", - EnumField = (MyEnum)(index % (Enum.GetNames(typeof(MyEnum)).Length)), - CollectionField = new List(collectionSize), - SimpleTypeList = new List(childListSize) - }; - for (int i = 0; i < collectionSize; ++i) - { - obj.CollectionField.Add(index + "." + i); - } - if (height > 1) - { - for (int i = 0; i < childListSize; ++i) - { - obj.SimpleTypeList.Add(CreateSimpleTypeWithFields(height - 1, index, i, collectionSize, childListSize)); - } - } - return obj; - } - - public static byte[] CreateByteArray(int size) - { - byte[] obj = new byte[size]; - for (int i = 0; i < obj.Length; ++i) - { - unchecked - { - obj[i] = (byte)i; - } - } - return obj; - } - - public static Dictionary CreateDictionaryOfIntString(int count) - { - Dictionary dictOfIntString = new Dictionary(count); - for (int i = 0; i < count; ++i) - { - dictOfIntString[i] = i.ToString(); - } - - return dictOfIntString; - } - - public static Dictionary CreateDictionaryOfIntSimpleType(int count) - { - var dictOfIntSimpleType = new Dictionary(count); - for (int i = 0; i < count; ++i) - { - dictOfIntSimpleType[i] = new SimpleType() { P1 = i.ToString(), P2 = i }; - } - - return dictOfIntSimpleType; - } - - public static List CreateListOfSimpleType(int count) - { - var listOfSimpleType = new List(count); - for(int i = 0; i < count; i++) - { - listOfSimpleType.Add(new SimpleType() { P1 = i.ToString(), P2 = i }); - } - - return listOfSimpleType; - } - - public static SimpleType[] CreateArrayOfSimpleType(int count) - { - var arrayOfSimpleType = new SimpleType[count]; - for(int i = 0; i < count; i++) - { - arrayOfSimpleType[i] = new SimpleType() { P1 = i.ToString(), P2 = i }; - } - - return arrayOfSimpleType; - } - - public static List CreateListOfInt(int count) - { - return Enumerable.Range(0, count).ToList(); - } - - public static DateTime[] CreateDateTimeArray(int count) - { - DateTime[] arr = new DateTime[count]; - int kind = (int)DateTimeKind.Unspecified; - int maxDateTimeKind = (int) DateTimeKind.Local; - DateTime val = DateTime.Now.AddHours(count/2); - for (int i = 0; i < count; i++) - { - arr[i] = DateTime.SpecifyKind(val, (DateTimeKind)kind); - val = val.AddHours(1); - kind = (kind + 1)%maxDateTimeKind; - } - - return arr; - } - - public static object GetSerializationObject(TestType testType, int testSize) - { - object obj = null; - switch (testType) - { - case TestType.ByteArray: - obj = CreateByteArray(testSize); - break; - case TestType.Dictionary: - obj = CreateDictionaryOfIntString(testSize); - break; - case TestType.ISerializable: - obj = new ClassImplementingIXmlSerialiable() { StringValue = "Hello world" }; - break; - case TestType.ListOfInt: - obj = CreateListOfInt(testSize); - break; - case TestType.SimpleType: - obj = CreateSimpleTypeWihtMoreProperties(testSize, 0, -1, 7, 2); - break; - case TestType.SimpleTypeWithFields: - obj = CreateSimpleTypeWithFields(testSize, 0, -1, 7, 2); - break; - case TestType.String: - obj = new string('k', testSize); - break; - case TestType.XmlElement: - XmlDocument xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(@""); - XmlElement xmlElement = xmlDoc.CreateElement("Element"); - xmlElement.InnerText = "Element innertext"; - obj = xmlElement; - break; - case TestType.DateTimeArray: - obj = CreateDateTimeArray(testSize); - break; - case TestType.ArrayOfSimpleType: - obj = CreateArrayOfSimpleType(testSize); - break; - case TestType.ListOfSimpleType: - obj = CreateListOfSimpleType(testSize); - break; - case TestType.DictionaryOfSimpleType: - obj = CreateDictionaryOfIntSimpleType(testSize); - break; - case TestType.SimpleStructWithProperties: - obj = new SimpleStructWithProperties() { Num = 1, Text = "Foo" }; - break; - default: - throw new ArgumentException(); - } - return obj; - } - - #endregion - - #region Methods to run serialization performance tests - - public static void RunSerializationPerformanceTest(int numberOfRuns, TestType testType, int testSize, ISerializerFactory serializerFactory) - { - var obj = GetSerializationObject(testType, testSize); - - var serializer = serializerFactory.GetSerializer(); - serializer.Init(obj); - - using (var stream = new MemoryStream()) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < numberOfRuns; i++) - { - serializer.Serialize(obj, stream); - stream.Position = 0; - } - } - } - } - } - - public static void RunDeserializationPerformanceTest(int numberOfRuns, TestType testType, int testSize, ISerializerFactory serializerFactory) - { - var obj = GetSerializationObject(testType, testSize); - - var serializer = serializerFactory.GetSerializer(); - serializer.Init(obj); - - using (var stream = new MemoryStream()) - { - serializer.Serialize(obj, stream); - stream.Position = 0; - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < numberOfRuns; i++) - { - serializer.Deserialize(stream); - stream.Position = 0; - } - } - } - } - } - - #endregion - } -} diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/System.Runtime.Serialization.Xml.PerformanceTests.csproj b/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/System.Runtime.Serialization.Xml.PerformanceTests.csproj deleted file mode 100644 index ec3204c83c66d..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/System.Runtime.Serialization.Xml.PerformanceTests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - {122A5432-C5B7-4293-AFDA-B24F4D54FDEF} - netstandard-Debug;netstandard-Release - - - - - - - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/XmlUTF8TextReaderTests.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/XmlUTF8TextReaderTests.cs deleted file mode 100644 index 848faef6f30e9..0000000000000 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/Performance/XmlUTF8TextReaderTests.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using System.Collections.Generic; -using System.IO; -using System.Xml; - -namespace System.Runtime.Serialization.Xml.Tests.Performance -{ - public class XmlUTF8TextReaderTests - { - // Testing - private static byte[] s_trivial = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6E, 0x67, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - - // ????? - private static byte[] s_normal = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - // ?????Testing - private static byte[] s_normalMore = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6E, 0x67, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - // ???Testing??? - private static byte[] s_normalMore2 = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6E, 0x67, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - - // ?????(invalid) - private static byte[] s_invalidExtraEF = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - private static byte[] s_invalidExtraEFBF = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0xBF, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - private static byte[] s_invalidExtraEFBFBE = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0xBF, 0xBE, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - private static byte[] s_invalidExtraEFBFBF = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0xBF, 0xBF, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - - // ?????(invalid)Testing - private static byte[] s_invalidExtraEFMore = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6E, 0x67, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - private static byte[] s_invalidExtraEFBFMore = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0xBF, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6E, 0x67, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - private static byte[] s_invalidExtraEFBFBFMore = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0xBF, 0xBF, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6E, 0x67, 0x3C, 0x2F, 0x52, 0x6F, 0x6F, 0x74, 0x3E }; - - // ?????(invalid)EOF - private static byte[] s_invalidExtraEFBFBF_EOF = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0x80, 0x80, 0xEF, 0xBF, 0xBF }; - private static byte[] s_invalidExtraEFBF_EOF = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF, 0xBF }; - private static byte[] s_invalidExtraEF_EOF = new byte[] { 0x3C, 0x52, 0x6F, 0x6F, 0x74, 0x3E, 0xEF, 0x80, 0x80, 0xEF }; - - // Dictionary - private static Dictionary s_tests = new Dictionary(); - - private static byte[] GenerateTestAsciiBytes(int numChars) - { - byte[] byteArray = new byte[numChars + 13]; - - int offset = 0; - - byteArray[offset++] = 0x3C; // < - byteArray[offset++] = 0x52; // R - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x74; // t - byteArray[offset++] = 0x3E; // > - - for (int i = 0; i < numChars; i++) - { - byteArray[offset++] = (byte)((int)'a' + i % 10); - } - - byteArray[offset++] = 0x3C; // < - byteArray[offset++] = 0x2F; // / - byteArray[offset++] = 0x52; // R - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x74; // t - byteArray[offset++] = 0x3E; // > - - return byteArray; - } - - private static byte[] GenerateTestEFBytes(int numChars) - { - byte[] byteArray = new byte[3 * numChars + 13]; - - int offset = 0; - - byteArray[offset++] = 0x3C; // < - byteArray[offset++] = 0x52; // R - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x74; // t - byteArray[offset++] = 0x3E; // > - - for (int i = 0; i < numChars; i++) - { - byteArray[offset++] = 0xEF; - byteArray[offset++] = 0xBF; - byteArray[offset++] = (byte)(0x0A + numChars % 10); - } - - byteArray[offset++] = 0x3C; // < - byteArray[offset++] = 0x2F; // / - byteArray[offset++] = 0x52; // R - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x6F; // o - byteArray[offset++] = 0x74; // t - byteArray[offset++] = 0x3E; // > - - return byteArray; - } - - private const int FiveMega = 5 * 1024 * 1024; - - public void RunPerfTest(byte[] testBytes, int iterations) - { - foreach (var iteration in Benchmark.Iterations) - { - using (MemoryStream testStream = new MemoryStream(testBytes)) - { - using (var reader = XmlDictionaryReader.CreateTextReader(testStream, XmlDictionaryReaderQuotas.Max)) - { - using (var stream = new MemoryStream()) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterations; i++) - { - while (reader.Read()) - { - ; - } - } - } - } - } - } - } - } - - [Benchmark] - public void TestAsciiBytes() - { - byte[] testBytes = GenerateTestAsciiBytes(FiveMega); - RunPerfTest(testBytes, 1000); - } - - [Benchmark] - public void TestEFBytes() - { - byte[] testBytes = GenerateTestEFBytes(FiveMega); - RunPerfTest(testBytes, 1000); - } - } -} From 18c875ca4ee7f1356006effae31cf004a086407e Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:56:16 +0100 Subject: [PATCH 29/45] remove System.Text.Encoding.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/e6534d135751bd284f9995ece24400643bbc5538 --- .../System.Text.Encoding.sln | 10 -- .../tests/Performance/Configurations.props | 7 -- .../tests/Performance/Perf.Encoding.cs | 111 ------------------ ...stem.Text.Encoding.PerformanceTests.csproj | 19 --- 4 files changed, 147 deletions(-) delete mode 100644 src/libraries/System.Text.Encoding/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Text.Encoding/tests/Performance/Perf.Encoding.cs delete mode 100644 src/libraries/System.Text.Encoding/tests/Performance/System.Text.Encoding.PerformanceTests.csproj diff --git a/src/libraries/System.Text.Encoding/System.Text.Encoding.sln b/src/libraries/System.Text.Encoding/System.Text.Encoding.sln index f047e4c021dd0..64ed9744724fc 100644 --- a/src/libraries/System.Text.Encoding/System.Text.Encoding.sln +++ b/src/libraries/System.Text.Encoding/System.Text.Encoding.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding.Tests" {635F30B9-5566-4096-B772-68FAA9B00DF4} = {635F30B9-5566-4096-B772-68FAA9B00DF4} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding.PerformanceTests", "tests\Performance\System.Text.Encoding.PerformanceTests.csproj", "{859C92CB-72FB-453C-A363-7CD025E29B1D}" - ProjectSection(ProjectDependencies) = postProject - {635F30B9-5566-4096-B772-68FAA9B00DF4} = {635F30B9-5566-4096-B772-68FAA9B00DF4} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.Encoding", "src\System.Text.Encoding.csproj", "{635F30B9-5566-4096-B772-68FAA9B00DF4}" ProjectSection(ProjectDependencies) = postProject {D5E689FD-4848-4E06-B6ED-35EA09AF9E20} = {D5E689FD-4848-4E06-B6ED-35EA09AF9E20} @@ -35,10 +30,6 @@ Global {3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {859C92CB-72FB-453C-A363-7CD025E29B1D}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {859C92CB-72FB-453C-A363-7CD025E29B1D}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {859C92CB-72FB-453C-A363-7CD025E29B1D}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {859C92CB-72FB-453C-A363-7CD025E29B1D}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {635F30B9-5566-4096-B772-68FAA9B00DF4}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {635F30B9-5566-4096-B772-68FAA9B00DF4}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {635F30B9-5566-4096-B772-68FAA9B00DF4}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {859C92CB-72FB-453C-A363-7CD025E29B1D} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {635F30B9-5566-4096-B772-68FAA9B00DF4} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {D5E689FD-4848-4E06-B6ED-35EA09AF9E20} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Text.Encoding/tests/Performance/Configurations.props b/src/libraries/System.Text.Encoding/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Text.Encoding/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Text.Encoding/tests/Performance/Perf.Encoding.cs b/src/libraries/System.Text.Encoding/tests/Performance/Perf.Encoding.cs deleted file mode 100644 index d561d639c059b..0000000000000 --- a/src/libraries/System.Text.Encoding/tests/Performance/Perf.Encoding.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text; -using Xunit; -using Microsoft.Xunit.Performance; -using System.Collections.Generic; - -namespace System.Text.Tests -{ - public class Perf_Encoding - { - public static IEnumerable EncodingSizeData() - { - int[] sizes = new int[] { 16, 32, 64, 128, 256, 512, 10000, 1000000 }; - string[] encs = new string[] { "utf-8", "ascii", "unicode" }; - foreach (int size in sizes) - foreach (string enc in encs) - yield return new object[] { size, enc }; - } - - [Benchmark] - [MemberData(nameof(EncodingSizeData))] - public void GetBytes(int size, string encName) - { - const int innerIterations = 100; - Encoding enc = Encoding.GetEncoding(encName); - PerfUtils utils = new PerfUtils(); - string toEncode = utils.CreateString(size); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - { - enc.GetBytes(toEncode); enc.GetBytes(toEncode); enc.GetBytes(toEncode); - enc.GetBytes(toEncode); enc.GetBytes(toEncode); enc.GetBytes(toEncode); - enc.GetBytes(toEncode); enc.GetBytes(toEncode); enc.GetBytes(toEncode); - } - } - - [Benchmark] - [MemberData(nameof(EncodingSizeData))] - public void GetString(int size, string encName) - { - const int innerIterations = 100; - Encoding enc = Encoding.GetEncoding(encName); - PerfUtils utils = new PerfUtils(); - byte[] bytes = enc.GetBytes(utils.CreateString(size)); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - { - enc.GetString(bytes); enc.GetString(bytes); enc.GetString(bytes); - enc.GetString(bytes); enc.GetString(bytes); enc.GetString(bytes); - enc.GetString(bytes); enc.GetString(bytes); enc.GetString(bytes); - } - } - - [Benchmark] - [MemberData(nameof(EncodingSizeData))] - public void GetChars(int size, string encName) - { - const int innerIterations = 100; - Encoding enc = Encoding.GetEncoding(encName); - PerfUtils utils = new PerfUtils(); - byte[] bytes = enc.GetBytes(utils.CreateString(size)); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - { - enc.GetChars(bytes); enc.GetChars(bytes); enc.GetChars(bytes); - enc.GetChars(bytes); enc.GetChars(bytes); enc.GetChars(bytes); - enc.GetChars(bytes); enc.GetChars(bytes); enc.GetChars(bytes); - } - } - - [Benchmark] - [MemberData(nameof(EncodingSizeData))] - public void GetEncoder(int size, string encName) - { - const int innerIterations = 10000; - Encoding enc = Encoding.GetEncoding(encName); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - { - enc.GetEncoder(); enc.GetEncoder(); enc.GetEncoder(); - enc.GetEncoder(); enc.GetEncoder(); enc.GetEncoder(); - enc.GetEncoder(); enc.GetEncoder(); enc.GetEncoder(); - } - } - - [Benchmark] - [MemberData(nameof(EncodingSizeData))] - public void GetByteCount(int size, string encName) - { - const int innerIterations = 100; - Encoding enc = Encoding.GetEncoding(encName); - PerfUtils utils = new PerfUtils(); - char[] chars = utils.CreateString(size).ToCharArray(); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - { - enc.GetByteCount(chars); enc.GetByteCount(chars); enc.GetByteCount(chars); - enc.GetByteCount(chars); enc.GetByteCount(chars); enc.GetByteCount(chars); - enc.GetByteCount(chars); enc.GetByteCount(chars); enc.GetByteCount(chars); - } - } - } -} diff --git a/src/libraries/System.Text.Encoding/tests/Performance/System.Text.Encoding.PerformanceTests.csproj b/src/libraries/System.Text.Encoding/tests/Performance/System.Text.Encoding.PerformanceTests.csproj deleted file mode 100644 index 48e4c17ed78be..0000000000000 --- a/src/libraries/System.Text.Encoding/tests/Performance/System.Text.Encoding.PerformanceTests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - true - {859C92CB-72FB-453C-A363-7CD025E29B1D} - netstandard-Debug;netstandard-Release - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 6a131443f395ab761097b5f52f554e9e8c8aa7cf Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:58:08 +0100 Subject: [PATCH 30/45] remove System.Text.RegularExpressions.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/f0a82cadcb36ff6903d48c7e1bf69bdb7a37ffc8 --- .../System.Text.RegularExpressions.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Regex.Cache.cs | 122 ----- .../tests/Performance/Perf.Regex.cs | 452 ------------------ .../tests/Performance/Perf.RegexRedux.cs | 70 --- ...RegularExpressions.PerformanceTests.csproj | 25 - .../tests/Performance/THIRD-PARTY-NOTICES | 31 -- 7 files changed, 717 deletions(-) delete mode 100644 src/libraries/System.Text.RegularExpressions/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.Cache.cs delete mode 100644 src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.cs delete mode 100644 src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.RegexRedux.cs delete mode 100644 src/libraries/System.Text.RegularExpressions/tests/Performance/System.Text.RegularExpressions.PerformanceTests.csproj delete mode 100644 src/libraries/System.Text.RegularExpressions/tests/Performance/THIRD-PARTY-NOTICES diff --git a/src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln b/src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln index 974d341285b94..bdeee004cd188 100644 --- a/src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln +++ b/src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressi {2C58640B-5BED-4E83-9554-CD2B9762643F} = {2C58640B-5BED-4E83-9554-CD2B9762643F} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions.PerformanceTests", "tests\Performance\System.Text.RegularExpressions.PerformanceTests.csproj", "{7F4B8C48-8692-4885-BF84-FEB7EA82E34B}" - ProjectSection(ProjectDependencies) = postProject - {2C58640B-5BED-4E83-9554-CD2B9762643F} = {2C58640B-5BED-4E83-9554-CD2B9762643F} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Text.RegularExpressions", "src\System.Text.RegularExpressions.csproj", "{2C58640B-5BED-4E83-9554-CD2B9762643F}" ProjectSection(ProjectDependencies) = postProject {B262B15E-13E6-4C1E-A25E-16D06E222A09} = {B262B15E-13E6-4C1E-A25E-16D06E222A09} @@ -35,10 +30,6 @@ Global {94B106C2-D574-4392-80AB-3EE308A078DF}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {94B106C2-D574-4392-80AB-3EE308A078DF}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {94B106C2-D574-4392-80AB-3EE308A078DF}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {7F4B8C48-8692-4885-BF84-FEB7EA82E34B}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {7F4B8C48-8692-4885-BF84-FEB7EA82E34B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {7F4B8C48-8692-4885-BF84-FEB7EA82E34B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {7F4B8C48-8692-4885-BF84-FEB7EA82E34B}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {2C58640B-5BED-4E83-9554-CD2B9762643F}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {2C58640B-5BED-4E83-9554-CD2B9762643F}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {2C58640B-5BED-4E83-9554-CD2B9762643F}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {94B106C2-D574-4392-80AB-3EE308A078DF} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {7F4B8C48-8692-4885-BF84-FEB7EA82E34B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {2C58640B-5BED-4E83-9554-CD2B9762643F} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {B262B15E-13E6-4C1E-A25E-16D06E222A09} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Text.RegularExpressions/tests/Performance/Configurations.props b/src/libraries/System.Text.RegularExpressions/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Text.RegularExpressions/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.Cache.cs b/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.Cache.cs deleted file mode 100644 index 99a1ff2caa88e..0000000000000 --- a/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.Cache.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Xunit; - -namespace System.Text.RegularExpressions.Tests -{ - public class Perf_Regex_Cache - { - private const int MaxConcurrency = 4; - private volatile bool _isMatch; - - private static string[] CreatePatterns(int total, int unique) - { - var regexps = new string[total]; - // create: - { - var i = 0; - for (; i < unique; i++) - { - // "(0+)" "(1+)" .. "(9+)(9+)(8+)" .. - var sb = new StringBuilder(); - foreach (var c in i.ToString()) - sb.Append("(" + c + "+)"); - regexps[i] = sb.ToString(); - } - for (; i < total; i++) regexps[i] = regexps[i % unique]; - } - - // shuffle: - const int someSeed = 101; // seed for reproducability - var random = new Random(someSeed); - for (var i = 0; i < total; i++) - { - var r = random.Next(i, total); - var t = regexps[i]; - regexps[i] = regexps[r]; - regexps[r] = t; - } - - return regexps; - } - - [Benchmark] - [MeasureGCAllocations] - [InlineData(400_000, 7, 15)] // default size, most common - [InlineData(400_000, 1, 15)] // default size, to test LRU - [InlineData(40_000, 7, 0)] // cache turned off - [InlineData(40_000, 1_600, 15)] // default size, to compare when cache used - [InlineData(40_000, 1_600, 800)] // larger size, to test cache is not O(n) - [InlineData(40_000, 1_600, 3_200)] // larger size, to test cache always hit - public void IsMatch(int total, int unique, int cacheSize) - { - var cacheSizeOld = Regex.CacheSize; - string[] patterns = CreatePatterns(total, unique); - - try - { - Regex.CacheSize = 0; // clean up cache - Regex.CacheSize = cacheSize; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - RunTest(0, total, patterns); - } - finally - { - Regex.CacheSize = cacheSizeOld; - } - } - - private void RunTest(int start, int total, string[] regexps) - { - for (var i = 0; i < total; i++) - _isMatch = Regex.IsMatch("0123456789", regexps[start + i]); - } - - [Benchmark] - [MeasureGCAllocations] - [InlineData(400_000, 7, 15)] // default size, most common - [InlineData(400_000, 1, 15)] // default size, to test LRU - [InlineData(40_000, 7, 0)] // cache turned off - [InlineData(40_000, 1_600, 15)] // default size, to compare when cache used - [InlineData(40_000, 1_600, 800)] // larger size, to test cache is not O(n) - [InlineData(40_000, 1_600, 3_200)] // larger size, to test cache always hit - public async Task IsMatch_Multithreading(int total, int unique, int cacheSize) - { - int cacheSizeOld = Regex.CacheSize; - string[] patterns = CreatePatterns(total, unique); - - try - { - Regex.CacheSize = 0; // clean up cache - Regex.CacheSize = cacheSize; - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - int sliceLength = total / MaxConcurrency; - var tasks = new Task[MaxConcurrency]; - - for (int i = 0; i < MaxConcurrency; i++) - { - int start = i * sliceLength; - tasks[i] = Task.Run(() => RunTest(start, sliceLength, patterns)); - } - - await Task.WhenAll(tasks); - } - } - } - finally - { - Regex.CacheSize = cacheSizeOld; - } - } - } -} diff --git a/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.cs b/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.cs deleted file mode 100644 index 96718a624faf5..0000000000000 --- a/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.Regex.cs +++ /dev/null @@ -1,452 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using Microsoft.Xunit.Performance; - -namespace System.Text.RegularExpressions.Tests -{ - /// - /// Performance tests for Regular Expressions - /// - public class Perf_Regex - { - private const int InnerIterations = 100; - - [Benchmark] - [MeasureGCAllocations] - public void Match() - { - var cacheSizeOld = Regex.CacheSize; - try - { - Regex.CacheSize = 0; // disable cache to get clearer results - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < InnerIterations; i++) - { - foreach (var test in Match_TestData()) - Regex.Match((string)test[1], (string)test[0], (RegexOptions)test[2]); - } - } - } - } - finally - { - Regex.CacheSize = cacheSizeOld; - } - } - - // A series of patterns (all valid and non pathological) and inputs (which they may or may not match) - public static IEnumerable Match_TestData() - { - yield return new object[] { "[abcd-[d]]+", "dddaabbccddd", RegexOptions.None }; - yield return new object[] { @"[\d-[357]]+", "33312468955", RegexOptions.None }; - yield return new object[] { @"[\d-[357]]+", "51246897", RegexOptions.None }; - yield return new object[] { @"[\d-[357]]+", "3312468977", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\w-[\d]]+", "0AZaz9", RegexOptions.None }; - yield return new object[] { @"[\w-[\p{Ll}]]+", "a09AZz", RegexOptions.None }; - yield return new object[] { @"[\d-[13579]]+", "1024689", RegexOptions.ECMAScript }; - yield return new object[] { @"[\d-[13579]]+", "\x066102468\x0660", RegexOptions.ECMAScript }; - yield return new object[] { @"[\d-[13579]]+", "\x066102468\x0660", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\p{Ll}-[ae-z]]+", "aaabbbcccdddeee", RegexOptions.None }; - yield return new object[] { @"[\p{Nd}-[2468]]+", "20135798", RegexOptions.None }; - yield return new object[] { @"[\P{Lu}-[ae-z]]+", "aaabbbcccdddeee", RegexOptions.None }; - yield return new object[] { @"[\P{Nd}-[\p{Ll}]]+", "az09AZ'[]", RegexOptions.None }; - yield return new object[] { "[abcd-[def]]+", "fedddaabbccddd", RegexOptions.None }; - yield return new object[] { @"[\d-[357a-z]]+", "az33312468955", RegexOptions.None }; - yield return new object[] { @"[\d-[de357fgA-Z]]+", "AZ51246897", RegexOptions.None }; - yield return new object[] { @"[\d-[357\p{Ll}]]+", "az3312468977", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y\s]]+", " \tbbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\w-[\d\p{Po}]]+", "!#0AZaz9", RegexOptions.None }; - yield return new object[] { @"[\w-[\p{Ll}\s]]+", "a09AZz", RegexOptions.None }; - yield return new object[] { @"[\d-[13579a-zA-Z]]+", "AZ1024689", RegexOptions.ECMAScript }; - yield return new object[] { @"[\d-[13579abcd]]+", "abcd\x066102468\x0660", RegexOptions.ECMAScript }; - yield return new object[] { @"[\d-[13579\s]]+", " \t\x066102468\x0660", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y\p{Po}]]+", "!#bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\w-[b-y!.,]]+", "!.,bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { "[\\w-[b-y\x00-\x0F]]+", "\0bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\p{Ll}-[ae-z0-9]]+", "09aaabbbcccdddeee", RegexOptions.None }; - yield return new object[] { @"[\p{Nd}-[2468az]]+", "az20135798", RegexOptions.None }; - yield return new object[] { @"[\P{Lu}-[ae-zA-Z]]+", "AZaaabbbcccdddeee", RegexOptions.None }; - yield return new object[] { @"[\P{Nd}-[\p{Ll}0123456789]]+", "09az09AZ'[]", RegexOptions.None }; - yield return new object[] { "[abc-[defg]]+", "dddaabbccddd", RegexOptions.None }; - yield return new object[] { @"[\d-[abc]]+", "abc09abc", RegexOptions.None }; - yield return new object[] { @"[\d-[a-zA-Z]]+", "az09AZ", RegexOptions.None }; - yield return new object[] { @"[\d-[\p{Ll}]]+", "az09az", RegexOptions.None }; - yield return new object[] { @"[\w-[\x00-\x0F]]+", "bbbaaaABYZ09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\w-[\s]]+", "0AZaz9", RegexOptions.None }; - yield return new object[] { @"[\w-[\W]]+", "0AZaz9", RegexOptions.None }; - yield return new object[] { @"[\w-[\p{Po}]]+", "#a09AZz!", RegexOptions.None }; - yield return new object[] { @"[\d-[\D]]+", "azAZ1024689", RegexOptions.ECMAScript }; - yield return new object[] { @"[\d-[a-zA-Z]]+", "azAZ\x066102468\x0660", RegexOptions.ECMAScript }; - yield return new object[] { @"[\d-[\p{Ll}]]+", "\x066102468\x0660", RegexOptions.None }; - yield return new object[] { @"[a-zA-Z0-9-[\s]]+", " \tazAZ09", RegexOptions.None }; - yield return new object[] { @"[a-zA-Z0-9-[\W]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[a-zA-Z0-9-[^a-zA-Z0-9]]+", "bbbaaaABCD09zzzyyy", RegexOptions.None }; - yield return new object[] { @"[\p{Ll}-[A-Z]]+", "AZaz09", RegexOptions.None }; - yield return new object[] { @"[\p{Nd}-[a-z]]+", "az09", RegexOptions.None }; - yield return new object[] { @"[\P{Lu}-[\p{Lu}]]+", "AZazAZ", RegexOptions.None }; - yield return new object[] { @"[\P{Lu}-[A-Z]]+", "AZazAZ", RegexOptions.None }; - yield return new object[] { @"[\P{Nd}-[\p{Nd}]]+", "azAZ09", RegexOptions.None }; - yield return new object[] { @"[\P{Nd}-[2-8]]+", "1234567890azAZ1234567890", RegexOptions.None }; - yield return new object[] { @"([ ]|[\w-[0-9]])+", "09az AZ90", RegexOptions.None }; - yield return new object[] { @"([0-9-[02468]]|[0-9-[13579]])+", "az1234567890za", RegexOptions.None }; - yield return new object[] { @"([^0-9-[a-zAE-Z]]|[\w-[a-zAF-Z]])+", "azBCDE1234567890BCDEFza", RegexOptions.None }; - yield return new object[] { @"([\p{Ll}-[aeiou]]|[^\w-[\s]])+", "aeiobcdxyz!@#aeio", RegexOptions.None }; - yield return new object[] { @"98[\d-[9]][\d-[8]][\d-[0]]", "98911 98881 98870 98871", RegexOptions.None }; - yield return new object[] { @"m[\w-[^aeiou]][\w-[^aeiou]]t", "mbbt mect meet", RegexOptions.None }; - yield return new object[] { "[abcdef-[^bce]]+", "adfbcefda", RegexOptions.None }; - yield return new object[] { "[^cde-[ag]]+", "agbfxyzga", RegexOptions.None }; - yield return new object[] { @"[\p{L}-[^\p{Lu}]]+", "09',.abcxyzABCXYZ", RegexOptions.None }; - yield return new object[] { @"[\p{IsGreek}-[\P{Lu}]]+", "\u0390\u03FE\u0386\u0388\u03EC\u03EE\u0400", RegexOptions.None }; - yield return new object[] { @"[\p{IsBasicLatin}-[G-L]]+", "GAFMZL", RegexOptions.None }; - yield return new object[] { "[a-zA-Z-[aeiouAEIOU]]+", "aeiouAEIOUbcdfghjklmnpqrstvwxyz", RegexOptions.None }; - yield return new object[] { @"^ - (?^ - ( - ( - (?[\d-[013-9]]) - | - [\d-[2-9]] - ) - (?(Octet2xx) - ( - (?[\d-[01-46-9]]) - | - [\d-[5-9]] - ) - ( - (?(Octet25x) - [\d-[6-9]] - | - [\d] - ) - ) - | - [\d]{2} - ) - ) - | - ([\d][\d]) - | - [\d] - )$" - , "255", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"[abcd\-d-[bc]]+", "bbbaaa---dddccc", RegexOptions.None }; - yield return new object[] { @"[abcd\-d-[bc]]+", "bbbaaa---dddccc", RegexOptions.None }; - yield return new object[] { @"[^a-f-[\x00-\x60\u007B-\uFFFF]]+", "aaafffgggzzz{{{", RegexOptions.None }; - yield return new object[] { @"[\[\]a-f-[[]]+", "gggaaafff]]][[[", RegexOptions.None }; - yield return new object[] { @"[\[\]a-f-[]]]+", "gggaaafff[[[]]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[-[]]]]", "a]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[-[]]]]", "b]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[-[]]]]", "c]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[-[]]]]", "d]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[[]]]]", "a]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[[]]]]", "b]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[[]]]]", "c]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[[]]]]", "d]]", RegexOptions.None }; - yield return new object[] { @"[ab\-\[cd-[[]]]]", "-]]", RegexOptions.None }; - yield return new object[] { @"[a-[c-e]]+", "bbbaaaccc", RegexOptions.None }; - yield return new object[] { @"[a-[c-e]]+", "```aaaccc", RegexOptions.None }; - yield return new object[] { @"[a-d\--[bc]]+", "cccaaa--dddbbb", RegexOptions.None }; - yield return new object[] { @"[\0- [bc]+", "!!!\0\0\t\t [[[[bbbcccaaa", RegexOptions.None }; - yield return new object[] { "[[abcd]-[bc]]+", "a-b]", RegexOptions.None }; - yield return new object[] { "[-[e-g]+", "ddd[[[---eeefffggghhh", RegexOptions.None }; - yield return new object[] { "[-e-g]+", "ddd---eeefffggghhh", RegexOptions.None }; - yield return new object[] { "[-e-g]+", "ddd---eeefffggghhh", RegexOptions.None }; - yield return new object[] { "[a-e - m-p]+", "---a b c d e m n o p---", RegexOptions.None }; - yield return new object[] { "[^-[bc]]", "b] c] -] aaaddd]", RegexOptions.None }; - yield return new object[] { "[^-[bc]]", "b] c] -] aaa]ddd]", RegexOptions.None }; - yield return new object[] { @"[a\-[bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None }; - yield return new object[] { @"[a\-[\-\-bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None }; - yield return new object[] { @"[a\-\[\-\[\-bc]+", "```bbbaaa---[[[cccddd", RegexOptions.None }; - yield return new object[] { @"[abc\--[b]]+", "[[[```bbbaaa---cccddd", RegexOptions.None }; - yield return new object[] { @"[abc\-z-[b]]+", "```aaaccc---zzzbbb", RegexOptions.None }; - yield return new object[] { @"[a-d\-[b]+", "```aaabbbcccddd----[[[[]]]", RegexOptions.None }; - yield return new object[] { @"[abcd\-d\-[bc]+", "bbbaaa---[[[dddccc", RegexOptions.None }; - yield return new object[] { "[a - c - [ b ] ]+", "dddaaa ccc [[[[ bbb ]]]", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { "[a - c - [ b ] +", "dddaaa ccc [[[[ bbb ]]]", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"(\p{Lu}\w*)\s(\p{Lu}\w*)", "Hello World", RegexOptions.None }; - yield return new object[] { @"(\p{Lu}\p{Ll}*)\s(\p{Lu}\p{Ll}*)", "Hello World", RegexOptions.None }; - yield return new object[] { @"(\P{Ll}\p{Ll}*)\s(\P{Ll}\p{Ll}*)", "Hello World", RegexOptions.None }; - yield return new object[] { @"(\P{Lu}+\p{Lu})\s(\P{Lu}+\p{Lu})", "hellO worlD", RegexOptions.None }; - yield return new object[] { @"(\p{Lt}\w*)\s(\p{Lt}*\w*)", "\u01C5ello \u01C5orld", RegexOptions.None }; - yield return new object[] { @"(\P{Lt}\w*)\s(\P{Lt}*\w*)", "Hello World", RegexOptions.None }; - yield return new object[] { @"[@-D]+", "eE?@ABCDabcdeE", RegexOptions.IgnoreCase }; - yield return new object[] { @"[>-D]+", "eE=>?@ABCDabcdeE", RegexOptions.IgnoreCase }; - yield return new object[] { @"[\u0554-\u0557]+", "\u0583\u0553\u0554\u0555\u0556\u0584\u0585\u0586\u0557\u0558", RegexOptions.IgnoreCase }; - yield return new object[] { @"[X-\]]+", "wWXYZxyz[\\]^", RegexOptions.IgnoreCase }; - yield return new object[] { @"[X-\u0533]+", "\u0551\u0554\u0560AXYZaxyz\u0531\u0532\u0533\u0561\u0562\u0563\u0564", RegexOptions.IgnoreCase }; - yield return new object[] { @"[X-a]+", "wWAXYZaxyz", RegexOptions.IgnoreCase }; - yield return new object[] { @"[X-c]+", "wWABCXYZabcxyz", RegexOptions.IgnoreCase }; - yield return new object[] { @"[X-\u00C0]+", "\u00C1\u00E1\u00C0\u00E0wWABCXYZabcxyz", RegexOptions.IgnoreCase }; - yield return new object[] { @"[\u0100\u0102\u0104]+", "\u00FF \u0100\u0102\u0104\u0101\u0103\u0105\u0106", RegexOptions.IgnoreCase }; - yield return new object[] { @"[B-D\u0130]+", "aAeE\u0129\u0131\u0068 BCDbcD\u0130\u0069\u0070", RegexOptions.IgnoreCase }; - yield return new object[] { @"[\u013B\u013D\u013F]+", "\u013A\u013B\u013D\u013F\u013C\u013E\u0140\u0141", RegexOptions.IgnoreCase }; - yield return new object[] { "(Cat)\r(Dog)", "Cat\rDog", RegexOptions.None }; - yield return new object[] { "(Cat)\t(Dog)", "Cat\tDog", RegexOptions.None }; - yield return new object[] { "(Cat)\f(Dog)", "Cat\fDog", RegexOptions.None }; - yield return new object[] { @"{5", "hello {5 world", RegexOptions.None }; - yield return new object[] { @"{5,", "hello {5, world", RegexOptions.None }; - yield return new object[] { @"{5,6", "hello {5,6 world", RegexOptions.None }; - yield return new object[] { @"(?n:(?cat)(\s+)(?dog))", "cat dog", RegexOptions.None }; - yield return new object[] { @"(?n:(cat)(\s+)(dog))", "cat dog", RegexOptions.None }; - yield return new object[] { @"(?n:(cat)(?\s+)(dog))", "cat dog", RegexOptions.None }; - yield return new object[] { @"(?x: - (?cat) # Cat statement - (\s+) # Whitespace chars - (?dog # Dog statement - ))", "cat dog", RegexOptions.None }; - yield return new object[] { @"(?+i:cat)", "CAT", RegexOptions.None }; - yield return new object[] { @"cat([\d]*)dog", "hello123cat230927dog1412d", RegexOptions.None }; - yield return new object[] { @"([\D]*)dog", "65498catdog58719", RegexOptions.None }; - yield return new object[] { @"cat([\s]*)dog", "wiocat dog3270", RegexOptions.None }; - yield return new object[] { @"cat([\S]*)", "sfdcatdog 3270", RegexOptions.None }; - yield return new object[] { @"cat([\w]*)", "sfdcatdog 3270", RegexOptions.None }; - yield return new object[] { @"cat([\W]*)dog", "wiocat dog3270", RegexOptions.None }; - yield return new object[] { @"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", RegexOptions.None }; - yield return new object[] { @"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", RegexOptions.None }; - yield return new object[] { @"(cat)([\x41]*)(dog)", "catAAAdog", RegexOptions.None }; - yield return new object[] { @"(cat)([\u0041]*)(dog)", "catAAAdog", RegexOptions.None }; - yield return new object[] { @"(cat)([\a]*)(dog)", "cat\a\a\adog", RegexOptions.None }; - yield return new object[] { @"(cat)([\b]*)(dog)", "cat\b\b\bdog", RegexOptions.None }; - yield return new object[] { @"(cat)([\e]*)(dog)", "cat\u001B\u001B\u001Bdog", RegexOptions.None }; - yield return new object[] { @"(cat)([\f]*)(dog)", "cat\f\f\fdog", RegexOptions.None }; - yield return new object[] { @"(cat)([\r]*)(dog)", "cat\r\r\rdog", RegexOptions.None }; - yield return new object[] { @"(cat)([\v]*)(dog)", "cat\v\v\vdog", RegexOptions.None }; - yield return new object[] { @"cat([\d]*)dog", "hello123cat230927dog1412d", RegexOptions.ECMAScript }; - yield return new object[] { @"([\D]*)dog", "65498catdog58719", RegexOptions.ECMAScript }; - yield return new object[] { @"cat([\s]*)dog", "wiocat dog3270", RegexOptions.ECMAScript }; - yield return new object[] { @"cat([\S]*)", "sfdcatdog 3270", RegexOptions.ECMAScript }; - yield return new object[] { @"cat([\w]*)", "sfdcatdog 3270", RegexOptions.ECMAScript }; - yield return new object[] { @"cat([\W]*)dog", "wiocat dog3270", RegexOptions.ECMAScript }; - yield return new object[] { @"([\p{Lu}]\w*)\s([\p{Lu}]\w*)", "Hello World", RegexOptions.ECMAScript }; - yield return new object[] { @"([\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)", "Hello World", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\d*dog", "hello123cat230927dog1412d", RegexOptions.ECMAScript }; - yield return new object[] { @"\D*(dog)", "65498catdog58719", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\s*(dog)", "wiocat dog3270", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\S*", "sfdcatdog 3270", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\w*", "sfdcatdog 3270", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\W*(dog)", "wiocat dog3270", RegexOptions.ECMAScript }; - yield return new object[] { @"\p{Lu}(\w*)\s\p{Lu}(\w*)", "Hello World", RegexOptions.ECMAScript }; - yield return new object[] { @"\P{Ll}\p{Ll}*\s\P{Ll}\p{Ll}*", "Hello World", RegexOptions.ECMAScript }; - yield return new object[] { @"cat(?dog)", "catcatdogdogcat", RegexOptions.None }; - yield return new object[] { @"(?cat)\s*(?dog)", "catcat dogdogcat", RegexOptions.None }; - yield return new object[] { @"(?<1>cat)\s*(?<1>dog)", "catcat dogdogcat", RegexOptions.None }; - yield return new object[] { @"(?<2048>cat)\s*(?<2048>dog)", "catcat dogdogcat", RegexOptions.None }; - yield return new object[] { @"(?cat)\w+(?dog)", "cat_Hello_World_dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\w+(?<-cat>dog)", "cat_Hello_World_dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\w+(?dog)", "cat_Hello_World_dog", RegexOptions.None }; - yield return new object[] { @"(?<1>cat)\w+(?dog)", "cat_Hello_World_dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\w+(?<2-cat>dog)", "cat_Hello_World_dog", RegexOptions.None }; - yield return new object[] { @"(?<1>cat)\w+(?<2-1>dog)", "cat_Hello_World_dog", RegexOptions.None }; - yield return new object[] { @"(?cat){", "STARTcat{", RegexOptions.None }; - yield return new object[] { @"(?cat){fdsa", "STARTcat{fdsa", RegexOptions.None }; - yield return new object[] { @"(?cat){1", "STARTcat{1", RegexOptions.None }; - yield return new object[] { @"(?cat){1END", "STARTcat{1END", RegexOptions.None }; - yield return new object[] { @"(?cat){1,", "STARTcat{1,", RegexOptions.None }; - yield return new object[] { @"(?cat){1,END", "STARTcat{1,END", RegexOptions.None }; - yield return new object[] { @"(?cat){1,2", "STARTcat{1,2", RegexOptions.None }; - yield return new object[] { @"(?cat){1,2END", "STARTcat{1,2END", RegexOptions.None }; - yield return new object[] { @"(cat) #cat - \s+ #followed by 1 or more whitespace - (dog) #followed by dog - ", "cat dog", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"(cat) #cat - \s+ #followed by 1 or more whitespace - (dog) #followed by dog", "cat dog", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"(cat) (?#cat) \s+ (?#followed by 1 or more whitespace) (dog) (?#followed by dog)", "cat dog", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"(?cat)(?dog)\k", "asdfcatdogcatdog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\k", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\k'cat'", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\'cat'", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\k<1>", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\k'1'", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\<1>", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\'1'", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\1", "asdfcat dogcat dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\1", "asdfcat dogcat dog", RegexOptions.ECMAScript }; - yield return new object[] { @"(?cat)\s+(?dog)\k", "asdfcat dogdog dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\2", "asdfcat dogdog dog", RegexOptions.None }; - yield return new object[] { @"(?cat)\s+(?dog)\2", "asdfcat dogdog dog", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\077)", "hellocat?dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\77)", "hellocat?dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\176)", "hellocat~dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\400)", "hellocat\0dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\300)", "hellocat\u00C0dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\300)", "hellocat\u00C0dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\477)", "hellocat\u003Fdogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\777)", "hellocat\u00FFdogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\7770)", "hellocat\u00FF0dogworld", RegexOptions.None }; - yield return new object[] { @"(cat)(\077)", "hellocat?dogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\77)", "hellocat?dogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\7)", "hellocat\adogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\40)", "hellocat dogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\040)", "hellocat dogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\176)", "hellocatcat76dogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\377)", "hellocat\u00FFdogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)(\400)", "hellocat 0Fdogworld", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\s+(?<2147483646>dog)", "asdlkcat dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)\s+(?<2147483647>dog)", "asdlkcat dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2a*)(dog)", "asdlkcat***dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2b*)(dog)", "asdlkcat+++dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2c*)(dog)", "asdlkcat,,,dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2d*)(dog)", "asdlkcat---dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2e*)(dog)", "asdlkcat...dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2A*)(dog)", "asdlkcat***dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2B*)(dog)", "asdlkcat+++dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2C*)(dog)", "asdlkcat,,,dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2D*)(dog)", "asdlkcat---dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\x2E*)(dog)", "asdlkcat...dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\c@*)(dog)", "asdlkcat\0\0dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cA*)(dog)", "asdlkcat\u0001dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\ca*)(dog)", "asdlkcat\u0001dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cC*)(dog)", "asdlkcat\u0003dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cc*)(dog)", "asdlkcat\u0003dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cD*)(dog)", "asdlkcat\u0004dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cd*)(dog)", "asdlkcat\u0004dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cX*)(dog)", "asdlkcat\u0018dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cx*)(dog)", "asdlkcat\u0018dogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cZ*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None }; - yield return new object[] { @"(cat)(\cz*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None }; - yield return new object[] { @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.None }; - yield return new object[] { @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.Multiline }; - yield return new object[] { @"\A(cat)\s+(dog)", "cat \n\n\n dog", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.None }; - yield return new object[] { @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.Multiline }; - yield return new object[] { @"(cat)\s+(dog)\Z", "cat \n\n\n dog", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.None }; - yield return new object[] { @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.Multiline }; - yield return new object[] { @"(cat)\s+(dog)\Z", "cat \n\n\n dog\n", RegexOptions.ECMAScript }; - yield return new object[] { @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.None }; - yield return new object[] { @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.Multiline }; - yield return new object[] { @"(cat)\s+(dog)\z", "cat \n\n\n dog", RegexOptions.ECMAScript }; - yield return new object[] { @"\b@cat", "123START123@catEND", RegexOptions.None }; - yield return new object[] { @"\b\cat)\s+(?dog)\s+\123\s+\234", "asdfcat dog cat23 dog34eia", RegexOptions.ECMAScript }; - yield return new object[] { @"
- (?> -
(?) | -
(?<-DEPTH>) | - .? - )*? - (?(DEPTH)(?!)) -
", "
this is some
red
text
", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"( - ((?'open'<+)[^<>]*)+ - ((?'close-open'>+)[^<>]*)+ - )+", "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"( - (?<)? - [^<>]? - (?>)? - )*", "<01deep_01<02deep_01<03deep_01>><02deep_02><02deep_03<03deep_03>>>", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"( - (?<[^/<>]*>)? - [^<>]? - (?]*>)? - )*", "Cat", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"( - (?<(?[^/<>]*)>)? - [^<>]? - (?>)? - )*", "catdog", RegexOptions.IgnorePatternWhitespace }; - yield return new object[] { @"([0-9]+?)([\w]+?)", "55488aheiaheiad", RegexOptions.ECMAScript }; - yield return new object[] { @"([0-9]+?)([a-z]+?)", "55488aheiaheiad", RegexOptions.ECMAScript }; - yield return new object[] { @"\G<%#(?.*?)?%>", @"<%# DataBinder.Eval(this, ""MyNumber"") %>", RegexOptions.Singleline }; - yield return new object[] { @"^[abcd]{0,0x10}*$", "a{0,0x10}}}", RegexOptions.None }; - yield return new object[] { @"([a-z]*?)([\w])", "cat", RegexOptions.IgnoreCase }; - yield return new object[] { @"^([a-z]*?)([\w])$", "cat", RegexOptions.IgnoreCase }; - yield return new object[] { @"([a-z]*)([\w])", "cat", RegexOptions.IgnoreCase }; - yield return new object[] { @"^([a-z]*)([\w])$", "cat", RegexOptions.IgnoreCase }; - yield return new object[] { @"(cat){", "cat{", RegexOptions.None }; - yield return new object[] { @"(cat){}", "cat{}", RegexOptions.None }; - yield return new object[] { @"(cat){,", "cat{,", RegexOptions.None }; - yield return new object[] { @"(cat){,}", "cat{,}", RegexOptions.None }; - yield return new object[] { @"(cat){cat}", "cat{cat}", RegexOptions.None }; - yield return new object[] { @"(cat){cat,5}", "cat{cat,5}", RegexOptions.None }; - yield return new object[] { @"(cat){5,dog}", "cat{5,dog}", RegexOptions.None }; - yield return new object[] { @"(cat){cat,dog}", "cat{cat,dog}", RegexOptions.None }; - yield return new object[] { @"(cat){,}?", "cat{,}?", RegexOptions.None }; - yield return new object[] { @"(cat){cat}?", "cat{cat}?", RegexOptions.None }; - yield return new object[] { @"(cat){cat,5}?", "cat{cat,5}?", RegexOptions.None }; - yield return new object[] { @"(cat){5,dog}?", "cat{5,dog}?", RegexOptions.None }; - yield return new object[] { @"(cat){cat,dog}?", "cat{cat,dog}?", RegexOptions.None }; - yield return new object[] { @"()", "cat", RegexOptions.None }; - yield return new object[] { @"(?)", "cat", RegexOptions.None }; - yield return new object[] { @"(?'cat')", "cat", RegexOptions.None }; - yield return new object[] { @"(?:)", "cat", RegexOptions.None }; - yield return new object[] { @"(?imn)", "cat", RegexOptions.None }; - yield return new object[] { @"(?imn)cat", "(?imn)cat", RegexOptions.None }; - yield return new object[] { @"(?=)", "cat", RegexOptions.None }; - yield return new object[] { @"(?<=)", "cat", RegexOptions.None }; - yield return new object[] { @"(?>)", "cat", RegexOptions.None }; - yield return new object[] { @"(?()|)", "(?()|)", RegexOptions.None }; - yield return new object[] { @"(?(cat)|)", "cat", RegexOptions.None }; - yield return new object[] { @"(?(cat)|)", "dog", RegexOptions.None }; - yield return new object[] { @"(?(cat)catdog|)", "catdog", RegexOptions.None }; - yield return new object[] { @"(?(cat)catdog|)", "dog", RegexOptions.None }; - yield return new object[] { @"(?(cat)dog|)", "dog", RegexOptions.None }; - yield return new object[] { @"(?(cat)dog|)", "cat", RegexOptions.None }; - yield return new object[] { @"(?(cat)|catdog)", "cat", RegexOptions.None }; - yield return new object[] { @"(?(cat)|catdog)", "catdog", RegexOptions.None }; - yield return new object[] { @"(?(cat)|dog)", "dog", RegexOptions.None }; - yield return new object[] { "([\u0000-\uFFFF-[azAZ09]]|[\u0000-\uFFFF-[^azAZ09]])+", "azAZBCDE1234567890BCDEFAZza", RegexOptions.None }; - yield return new object[] { "[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[a]]]]]]+", "abcxyzABCXYZ123890", RegexOptions.None }; - yield return new object[] { "[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[\u0000-\uFFFF-[a]]]]]]]+", "bcxyzABCXYZ123890a", RegexOptions.None }; - yield return new object[] { "[\u0000-\uFFFF-[\\p{P}\\p{S}\\p{C}]]+", "!@`';.,$+<>=\x0001\x001FazAZ09", RegexOptions.None }; - yield return new object[] { @"[\uFFFD-\uFFFF]+", "\uFFFC\uFFFD\uFFFE\uFFFF", RegexOptions.IgnoreCase }; - yield return new object[] { @"[\uFFFC-\uFFFE]+", "\uFFFB\uFFFC\uFFFD\uFFFE\uFFFF", RegexOptions.IgnoreCase }; - yield return new object[] { @"([a*]*)+?$", "ab", RegexOptions.None }; - yield return new object[] { @"(a*)+?$", "b", RegexOptions.None }; - } - } -} diff --git a/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.RegexRedux.cs b/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.RegexRedux.cs deleted file mode 100644 index de980c885c69a..0000000000000 --- a/src/libraries/System.Text.RegularExpressions/tests/Performance/Perf.RegexRedux.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Diagnostics; -using System.Threading; -using System.Collections.Generic; -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Text.RegularExpressions.Tests -{ - public class RegexRedux - { - static readonly string input = File.ReadAllText(Path.Combine("regexredux", "200_000.in")); - - static Regex regex(string re, RegexOptions options) - { - return new Regex(re, options); - } - - static string regexCount(string s, string r, RegexOptions options) - { - int c = 0; - var m = regex(r, options).Match(s); - while (m.Success) { c++; m = m.NextMatch(); } - return r + " " + c; - } - - [Benchmark] - [InlineData(RegexOptions.None)] - [InlineData(RegexOptions.Compiled)] - public void RegexReduxMini(RegexOptions options) - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - { - string sequences = input; - var initialLength = sequences.Length; - sequences = Regex.Replace(sequences, ">.*\n|\n", ""); - - var magicTask = Task.Run(() => - { - var newseq = regex("tHa[Nt]", options).Replace(sequences, "<4>"); - newseq = regex("aND|caN|Ha[DS]|WaS", options).Replace(newseq, "<3>"); - newseq = regex("a[NSt]|BY", options).Replace(newseq, "<2>"); - newseq = regex("<[^>]*>", options).Replace(newseq, "|"); - newseq = regex("\\|[^|][^|]*\\|", options).Replace(newseq, "-"); - return newseq.Length; - }); - - var variant2 = Task.Run(() => regexCount(sequences, "[cgt]gggtaaa|tttaccc[acg]", options)); - var variant3 = Task.Run(() => regexCount(sequences, "a[act]ggtaaa|tttacc[agt]t", options)); - var variant7 = Task.Run(() => regexCount(sequences, "agggt[cgt]aa|tt[acg]accct", options)); - var variant6 = Task.Run(() => regexCount(sequences, "aggg[acg]aaa|ttt[cgt]ccct", options)); - var variant4 = Task.Run(() => regexCount(sequences, "ag[act]gtaaa|tttac[agt]ct", options)); - var variant5 = Task.Run(() => regexCount(sequences, "agg[act]taaa|ttta[agt]cct", options)); - var variant1 = Task.Run(() => regexCount(sequences, "agggtaaa|tttaccct", options)); - var variant9 = Task.Run(() => regexCount(sequences, "agggtaa[cgt]|[acg]ttaccct", options)); - var variant8 = Task.Run(() => regexCount(sequences, "agggta[cgt]a|t[acg]taccct", options)); - - Task.WaitAll(magicTask, variant1, variant2, variant3, variant4, variant5, variant6, variant7, variant8, variant9); - } - } - } -} diff --git a/src/libraries/System.Text.RegularExpressions/tests/Performance/System.Text.RegularExpressions.PerformanceTests.csproj b/src/libraries/System.Text.RegularExpressions/tests/Performance/System.Text.RegularExpressions.PerformanceTests.csproj deleted file mode 100644 index 07d7d9fa90259..0000000000000 --- a/src/libraries/System.Text.RegularExpressions/tests/Performance/System.Text.RegularExpressions.PerformanceTests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - {7F4B8C48-8692-4885-BF84-FEB7EA82E34B} - netstandard-Debug;netstandard-Release - - - - - - - Common\System\PerfUtils.cs - - - - - %(RecursiveDir)%(Filename)%(Extension) - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file diff --git a/src/libraries/System.Text.RegularExpressions/tests/Performance/THIRD-PARTY-NOTICES b/src/libraries/System.Text.RegularExpressions/tests/Performance/THIRD-PARTY-NOTICES deleted file mode 100644 index 51b5799e357fc..0000000000000 --- a/src/libraries/System.Text.RegularExpressions/tests/Performance/THIRD-PARTY-NOTICES +++ /dev/null @@ -1,31 +0,0 @@ -.NET Core uses third-party libraries or other resources that may be -distributed under licenses different than the .NET Core software. - -In the event that we accidentally failed to list a required notice, please -bring it to our attention. Post an issue or email us: - - dotnet@microsoft.com - -The attached notices are provided for information only. - -=============== - -The Computer Language -Benchmarks Game -Revised BSD license -This is a specific instance of the Open Source Initiative (OSI) BSD license template. - -Copyright (c) 2004-2008 Brent Fulgham, 2005-2018 Isaac Gouy - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -Neither the name of "The Computer Language Benchmarks Game" nor the name of "The Computer Language Shootout Benchmarks" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - From f06b476dec500205e6207dd2adc3ecf119a02c9b Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 07:59:07 +0100 Subject: [PATCH 31/45] remove System.Threading.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/08e5230556dd87d279a3df12d73d243452828a75 --- .../System.Threading/System.Threading.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.EventWaitHandle.cs | 33 --- .../tests/Performance/Perf.Interlocked.cs | 189 ------------------ .../tests/Performance/Perf.Lock.cs | 31 --- .../tests/Performance/Perf.Monitor.cs | 49 ----- .../tests/Performance/Perf.SpinLock.cs | 53 ----- .../tests/Performance/Perf.Volatile.cs | 48 ----- .../System.Threading.PerformanceTests.csproj | 23 --- 9 files changed, 443 deletions(-) delete mode 100644 src/libraries/System.Threading/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Threading/tests/Performance/Perf.EventWaitHandle.cs delete mode 100644 src/libraries/System.Threading/tests/Performance/Perf.Interlocked.cs delete mode 100644 src/libraries/System.Threading/tests/Performance/Perf.Lock.cs delete mode 100644 src/libraries/System.Threading/tests/Performance/Perf.Monitor.cs delete mode 100644 src/libraries/System.Threading/tests/Performance/Perf.SpinLock.cs delete mode 100644 src/libraries/System.Threading/tests/Performance/Perf.Volatile.cs delete mode 100644 src/libraries/System.Threading/tests/Performance/System.Threading.PerformanceTests.csproj diff --git a/src/libraries/System.Threading/System.Threading.sln b/src/libraries/System.Threading/System.Threading.sln index 2bf2fa31993a7..8dd0c96e634c2 100644 --- a/src/libraries/System.Threading/System.Threading.sln +++ b/src/libraries/System.Threading/System.Threading.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tests", "t {604027F5-1DFC-42F4-B4FE-61F8789BA647} = {604027F5-1DFC-42F4-B4FE-61F8789BA647} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.PerformanceTests", "tests\Performance\System.Threading.PerformanceTests.csproj", "{7AB03FFA-7D4D-4248-9702-3D2785859C18}" - ProjectSection(ProjectDependencies) = postProject - {604027F5-1DFC-42F4-B4FE-61F8789BA647} = {604027F5-1DFC-42F4-B4FE-61F8789BA647} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "src\System.Threading.csproj", "{604027F5-1DFC-42F4-B4FE-61F8789BA647}" ProjectSection(ProjectDependencies) = postProject {F59F13CA-829A-4D02-9A1D-E40E61257177} = {F59F13CA-829A-4D02-9A1D-E40E61257177} @@ -35,10 +30,6 @@ Global {18EF66B3-51EE-46D8-B283-1CB6A1197813}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {18EF66B3-51EE-46D8-B283-1CB6A1197813}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {18EF66B3-51EE-46D8-B283-1CB6A1197813}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {7AB03FFA-7D4D-4248-9702-3D2785859C18}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {7AB03FFA-7D4D-4248-9702-3D2785859C18}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {7AB03FFA-7D4D-4248-9702-3D2785859C18}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {7AB03FFA-7D4D-4248-9702-3D2785859C18}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {604027F5-1DFC-42F4-B4FE-61F8789BA647}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {604027F5-1DFC-42F4-B4FE-61F8789BA647}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {604027F5-1DFC-42F4-B4FE-61F8789BA647}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {18EF66B3-51EE-46D8-B283-1CB6A1197813} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {7AB03FFA-7D4D-4248-9702-3D2785859C18} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {604027F5-1DFC-42F4-B4FE-61F8789BA647} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {F59F13CA-829A-4D02-9A1D-E40E61257177} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Threading/tests/Performance/Configurations.props b/src/libraries/System.Threading/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Threading/tests/Performance/Perf.EventWaitHandle.cs b/src/libraries/System.Threading/tests/Performance/Perf.EventWaitHandle.cs deleted file mode 100644 index 448c978bb14c9..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Perf.EventWaitHandle.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Microsoft.Xunit.Performance; - -namespace System.Threading.Tests -{ - public class Perf_EventWaitHandle - { - private const int IterationCount = 100_000; - - [Benchmark(InnerIterationCount = IterationCount)] - public void Set_Reset() - { - using (EventWaitHandle are = new EventWaitHandle(false, EventResetMode.AutoReset)) - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - are.Set(); - are.Reset(); - } - } - } - } - } - } -} diff --git a/src/libraries/System.Threading/tests/Performance/Perf.Interlocked.cs b/src/libraries/System.Threading/tests/Performance/Perf.Interlocked.cs deleted file mode 100644 index e66deb3fed2a2..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Perf.Interlocked.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Threading.Tests -{ - public class Perf_Interlocked - { - private const int IterationCount = 10_000_000; - - [Benchmark(InnerIterationCount = IterationCount)] - public static void Increment_int() - { - int location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Increment(ref location); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public static void Decrement_int() - { - int location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Decrement(ref location); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public void Increment_long() - { - long location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Increment(ref location); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public void Decrement_long() - { - long location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Decrement(ref location); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public void Add_int() - { - int location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Add(ref location, 2); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public void Add_long() - { - long location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Add(ref location, 2); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public static void Exchange_int() - { - int location = 0; - int newValue = 1; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Exchange(ref location, newValue); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public static void Exchange_long() - { - long location = 0; - long newValue = 1; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.Exchange(ref location, newValue); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public static void CompareExchange_int() - { - int location = 0; - int newValue = 1; - int comparand = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.CompareExchange(ref location, newValue, comparand); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public static void CompareExchange_long() - { - long location = 0; - long newValue = 1; - long comparand = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Interlocked.CompareExchange(ref location, newValue, comparand); - } - } - } - } - } -} diff --git a/src/libraries/System.Threading/tests/Performance/Perf.Lock.cs b/src/libraries/System.Threading/tests/Performance/Perf.Lock.cs deleted file mode 100644 index 8f7d19efa281c..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Perf.Lock.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using Microsoft.Xunit.Performance; - -namespace System.Threading.Tests -{ - public class Perf_Lock - { - private const int IterationCount = 2_000_000; - - [Benchmark(InnerIterationCount = IterationCount)] - public static void ReaderWriterLockSlimPerf() - { - ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim(); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - rwLock.EnterReadLock(); - rwLock.ExitReadLock(); - } - } - } - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Threading/tests/Performance/Perf.Monitor.cs b/src/libraries/System.Threading/tests/Performance/Perf.Monitor.cs deleted file mode 100644 index 1037b63bcf3ea..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Perf.Monitor.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Threading.Tests -{ - public class Perf_Monitor - { - private const int IterationCount = 4_000_000; - - [Benchmark(InnerIterationCount = IterationCount)] - public static void EnterExit() - { - object sync = new object(); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Monitor.Enter(sync); - Monitor.Exit(sync); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public static void TryEnterExit() - { - object sync = new object(); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Monitor.TryEnter(sync, 0); - Monitor.Exit(sync); - } - } - } - } - } -} diff --git a/src/libraries/System.Threading/tests/Performance/Perf.SpinLock.cs b/src/libraries/System.Threading/tests/Performance/Perf.SpinLock.cs deleted file mode 100644 index e84b5f6254359..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Perf.SpinLock.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Threading.Tests -{ - public class Perf_SpinLock - { - private const int IterationCount = 1_000_000; - - [Benchmark(InnerIterationCount = IterationCount)] - public void EnterExit() - { - SpinLock spinLock = new SpinLock(); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - bool lockTaken = false; - - spinLock.Enter(ref lockTaken); - spinLock.Exit(); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public void TryEnterExit() - { - SpinLock spinLock = new SpinLock(); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - bool lockTaken = false; - - spinLock.TryEnter(0, ref lockTaken); - spinLock.Exit(); - } - } - } - } - } -} diff --git a/src/libraries/System.Threading/tests/Performance/Perf.Volatile.cs b/src/libraries/System.Threading/tests/Performance/Perf.Volatile.cs deleted file mode 100644 index 8c07b058bfeeb..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/Perf.Volatile.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; - -namespace System.Threading.Tests -{ - public class Perf_Volatile - { - private const int IterationCount = 100_000_000; - - [Benchmark(InnerIterationCount = IterationCount)] - public void Read_double() - { - double location = 0; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Volatile.Read(ref location); - } - } - } - } - - [Benchmark(InnerIterationCount = IterationCount)] - public void Write_double() - { - double location = 0; - double newValue = 1; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < IterationCount; i++) - { - Volatile.Write(ref location, newValue); - } - } - } - } - } -} diff --git a/src/libraries/System.Threading/tests/Performance/System.Threading.PerformanceTests.csproj b/src/libraries/System.Threading/tests/Performance/System.Threading.PerformanceTests.csproj deleted file mode 100644 index 231643a0f7a95..0000000000000 --- a/src/libraries/System.Threading/tests/Performance/System.Threading.PerformanceTests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - {7AB03FFA-7D4D-4248-9702-3D2785859C18} - netstandard-Debug;netstandard-Release - - - - - - - Common\System\PerfUtils.cs - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 1caeb5c5dc56c4a0c18be34bc75f80251be1ff89 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:00:40 +0100 Subject: [PATCH 32/45] remove System.Threading.Channels.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/a8f8f3912703a511000bd41aaeea0accf2de613f --- .../System.Threading.Channels.sln | 10 -- .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.Channel.cs | 129 ------------------ ...Threading.Channels.PerformanceTests.csproj | 18 --- 4 files changed, 164 deletions(-) delete mode 100644 src/libraries/System.Threading.Channels/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Threading.Channels/tests/Performance/Perf.Channel.cs delete mode 100644 src/libraries/System.Threading.Channels/tests/Performance/System.Threading.Channels.PerformanceTests.csproj diff --git a/src/libraries/System.Threading.Channels/System.Threading.Channels.sln b/src/libraries/System.Threading.Channels/System.Threading.Channels.sln index 10a7ca1065c0e..93cfbdea9b0f8 100644 --- a/src/libraries/System.Threading.Channels/System.Threading.Channels.sln +++ b/src/libraries/System.Threading.Channels/System.Threading.Channels.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Channels.T {AAADA5D3-CF64-4E9D-943C-EFDC006D6366} = {AAADA5D3-CF64-4E9D-943C-EFDC006D6366} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Channels.PerformanceTests", "tests\Performance\System.Threading.Channels.PerformanceTests.csproj", "{856BC941-58C3-4568-AAF2-238349DFA53E}" - ProjectSection(ProjectDependencies) = postProject - {AAADA5D3-CF64-4E9D-943C-EFDC006D6366} = {AAADA5D3-CF64-4E9D-943C-EFDC006D6366} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Channels", "src\System.Threading.Channels.csproj", "{AAADA5D3-CF64-4E9D-943C-EFDC006D6366}" ProjectSection(ProjectDependencies) = postProject {97DB4782-7AB3-4F4C-B716-CF722A0E6066} = {97DB4782-7AB3-4F4C-B716-CF722A0E6066} @@ -35,10 +30,6 @@ Global {1AF01469-DBFC-4BA1-9331-8E39AA639FEE}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {1AF01469-DBFC-4BA1-9331-8E39AA639FEE}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {1AF01469-DBFC-4BA1-9331-8E39AA639FEE}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {856BC941-58C3-4568-AAF2-238349DFA53E}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {856BC941-58C3-4568-AAF2-238349DFA53E}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {856BC941-58C3-4568-AAF2-238349DFA53E}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {856BC941-58C3-4568-AAF2-238349DFA53E}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {AAADA5D3-CF64-4E9D-943C-EFDC006D6366}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {AAADA5D3-CF64-4E9D-943C-EFDC006D6366}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {AAADA5D3-CF64-4E9D-943C-EFDC006D6366}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {1AF01469-DBFC-4BA1-9331-8E39AA639FEE} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {856BC941-58C3-4568-AAF2-238349DFA53E} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {AAADA5D3-CF64-4E9D-943C-EFDC006D6366} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {97DB4782-7AB3-4F4C-B716-CF722A0E6066} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Threading.Channels/tests/Performance/Configurations.props b/src/libraries/System.Threading.Channels/tests/Performance/Configurations.props deleted file mode 100644 index 89d6ac0f025b9..0000000000000 --- a/src/libraries/System.Threading.Channels/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netcoreapp; - - - \ No newline at end of file diff --git a/src/libraries/System.Threading.Channels/tests/Performance/Perf.Channel.cs b/src/libraries/System.Threading.Channels/tests/Performance/Perf.Channel.cs deleted file mode 100644 index 78b7ab1f6c18d..0000000000000 --- a/src/libraries/System.Threading.Channels/tests/Performance/Perf.Channel.cs +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Threading.Tasks; -using Microsoft.Xunit.Performance; - -namespace System.Threading.Channels.Tests -{ - public sealed class UnboundedChannelPerfTests : PerfTests - { - public override Channel CreateChannel() => Channel.CreateUnbounded(); - } - - public sealed class SpscUnboundedChannelPerfTests : PerfTests - { - public override Channel CreateChannel() => Channel.CreateUnbounded(new UnboundedChannelOptions { SingleReader = true, SingleWriter = true }); - } - - public sealed class BoundedChannelPerfTests : PerfTests - { - public override Channel CreateChannel() => Channel.CreateBounded(10); - } - - public abstract class PerfTests - { - public abstract Channel CreateChannel(); - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public void TryWriteThenTryRead() - { - Channel channel = CreateChannel(); - ChannelReader reader = channel.Reader; - ChannelWriter writer = channel.Writer; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - writer.TryWrite(i); - reader.TryRead(out _); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public async Task WriteAsyncThenReadAsync() - { - Channel channel = CreateChannel(); - ChannelReader reader = channel.Reader; - ChannelWriter writer = channel.Writer; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - await writer.WriteAsync(i); - await reader.ReadAsync(); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public async Task ReadAsyncThenWriteAsync() - { - Channel channel = CreateChannel(); - ChannelReader reader = channel.Reader; - ChannelWriter writer = channel.Writer; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iters; i++) - { - ValueTask r = reader.ReadAsync(); - await writer.WriteAsync(42); - await r; - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public async Task PingPong() - { - Channel channel1 = CreateChannel(); - Channel channel2 = CreateChannel(); - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - await Task.WhenAll( - Task.Run(async () => - { - ChannelReader reader = channel1.Reader; - ChannelWriter writer = channel2.Writer; - for (int i = 0; i < iters; i++) - { - await writer.WriteAsync(i); - await reader.ReadAsync(); - } - }), - Task.Run(async () => - { - ChannelWriter writer = channel1.Writer; - ChannelReader reader = channel2.Reader; - for (int i = 0; i < iters; i++) - { - await reader.ReadAsync(); - await writer.WriteAsync(i); - } - })); - } - } - } - } -} diff --git a/src/libraries/System.Threading.Channels/tests/Performance/System.Threading.Channels.PerformanceTests.csproj b/src/libraries/System.Threading.Channels/tests/Performance/System.Threading.Channels.PerformanceTests.csproj deleted file mode 100644 index 5af11be0c5d2a..0000000000000 --- a/src/libraries/System.Threading.Channels/tests/Performance/System.Threading.Channels.PerformanceTests.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - {856BC941-58C3-4568-AAF2-238349DFA53E} - netcoreapp-Debug;netcoreapp-Release - - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From fc150aecda26fcbb58940e55217b7f328c9206ec Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:02:20 +0100 Subject: [PATCH 33/45] remove System.Threading.Tasks.Extensions.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/8d9f3d110780f72b34a3adf94cd33ad72bd9c605 --- .../System.Threading.Tasks.Extensions.sln | 10 - .../tests/Performance/Configurations.props | 7 - .../tests/Performance/Perf.ValueTask.cs | 259 ------------------ ...g.Tasks.Extensions.PerformanceTests.csproj | 24 -- 4 files changed, 300 deletions(-) delete mode 100644 src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Perf.ValueTask.cs delete mode 100644 src/libraries/System.Threading.Tasks.Extensions/tests/Performance/System.Threading.Tasks.Extensions.PerformanceTests.csproj diff --git a/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln b/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln index cdac3df97626f..19b2bfaad2432 100644 --- a/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln +++ b/src/libraries/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Exte {DE90AD0B-649D-4062-B8D9-9658DE140532} = {DE90AD0B-649D-4062-B8D9-9658DE140532} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Extensions.PerformanceTests", "tests\Performance\System.Threading.Tasks.Extensions.PerformanceTests.csproj", "{77E38A48-61ED-4D79-9136-D88617EE3558}" - ProjectSection(ProjectDependencies) = postProject - {DE90AD0B-649D-4062-B8D9-9658DE140532} = {DE90AD0B-649D-4062-B8D9-9658DE140532} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading.Tasks.Extensions", "src\SystemThreading.Tasks.Extensions.csproj", "{DE90AD0B-649D-4062-B8D9-9658DE140532}" ProjectSection(ProjectDependencies) = postProject {0DF7FA9A-E7D3-4CEF-862B-A37F5BBBB54C} = {0DF7FA9A-E7D3-4CEF-862B-A37F5BBBB54C} @@ -35,10 +30,6 @@ Global {275B161B-D525-48A0-B1DE-344273AB9A99}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {275B161B-D525-48A0-B1DE-344273AB9A99}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {275B161B-D525-48A0-B1DE-344273AB9A99}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {77E38A48-61ED-4D79-9136-D88617EE3558}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {77E38A48-61ED-4D79-9136-D88617EE3558}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {77E38A48-61ED-4D79-9136-D88617EE3558}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {77E38A48-61ED-4D79-9136-D88617EE3558}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {DE90AD0B-649D-4062-B8D9-9658DE140532}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU {DE90AD0B-649D-4062-B8D9-9658DE140532}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU {DE90AD0B-649D-4062-B8D9-9658DE140532}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {275B161B-D525-48A0-B1DE-344273AB9A99} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {77E38A48-61ED-4D79-9136-D88617EE3558} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {DE90AD0B-649D-4062-B8D9-9658DE140532} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {0DF7FA9A-E7D3-4CEF-862B-A37F5BBBB54C} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Configurations.props b/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Configurations.props deleted file mode 100644 index a1eadd7648d83..0000000000000 --- a/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netcoreapp; - - - diff --git a/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Perf.ValueTask.cs b/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Perf.ValueTask.cs deleted file mode 100644 index bfb1860153222..0000000000000 --- a/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/Perf.ValueTask.cs +++ /dev/null @@ -1,259 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; -using System.Threading.Tasks.Sources; -using System.Threading.Tasks.Sources.Tests; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Threading.Tasks -{ - public class ValueTaskPerfTest - { - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task Await_FromResult() - { - ValueTask vt = new ValueTask(42); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await vt; - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task Await_FromCompletedTask() - { - ValueTask vt = new ValueTask(Task.FromResult(42)); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await vt; - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task Await_FromCompletedValueTaskSource() - { - ValueTask vt = new ValueTask(ManualResetValueTaskSourceFactory.Completed(42), 0); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await vt; - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromResult() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask((int)i); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromResult_ConfigureAwait() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask((int)i).ConfigureAwait(false); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromCompletedTask() - { - Task t = Task.FromResult(42); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask(t); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromCompletedTask_ConfigureAwait() - { - Task t = Task.FromResult(42); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask(t).ConfigureAwait(false); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromCompletedValueTaskSource() - { - IValueTaskSource vts = ManualResetValueTaskSourceFactory.Completed(42); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask(vts, 0); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromCompletedValueTaskSource_ConfigureAwait() - { - IValueTaskSource vts = ManualResetValueTaskSourceFactory.Completed(42); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask(vts, 0).ConfigureAwait(false); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromYieldingAsyncMethod() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - await new ValueTask(YieldOnce()); - } - } - } - } - - [Benchmark(InnerIterationCount = 1_000_000), MeasureGCAllocations] - public async Task CreateAndAwait_FromDelayedTCS() - { - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - var tcs = new TaskCompletionSource(); - ValueTask vt = AwaitTcsAsValueTask(tcs); - tcs.SetResult(42); - await vt; - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public void Copy_PassAsArgumentAndReturn_FromResult() - { - ValueTask vt = new ValueTask(42); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - vt = ReturnValueTask(vt); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public void Copy_PassAsArgumentAndReturn_FromTask() - { - ValueTask vt = new ValueTask(Task.FromResult(42)); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - vt = ReturnValueTask(vt); - } - } - } - } - - [Benchmark(InnerIterationCount = 10_000_000), MeasureGCAllocations] - public void Copy_PassAsArgumentAndReturn_FromValueTaskSource() - { - ValueTask vt = new ValueTask(ManualResetValueTaskSourceFactory.Completed(42), 0); - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - long iters = Benchmark.InnerIterationCount; - using (iteration.StartMeasurement()) - { - for (long i = 0; i < iters; i++) - { - vt = ReturnValueTask(vt); - } - } - } - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static ValueTask ReturnValueTask(ValueTask vt) => vt; - - private async ValueTask AwaitTcsAsValueTask(TaskCompletionSource tcs) => await new ValueTask(tcs.Task).ConfigureAwait(false); - - private async Task YieldOnce() { await Task.Yield(); return 42; } - } -} diff --git a/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/System.Threading.Tasks.Extensions.PerformanceTests.csproj b/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/System.Threading.Tasks.Extensions.PerformanceTests.csproj deleted file mode 100644 index 4cfb28e785770..0000000000000 --- a/src/libraries/System.Threading.Tasks.Extensions/tests/Performance/System.Threading.Tasks.Extensions.PerformanceTests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - {77E38A48-61ED-4D79-9136-D88617EE3558} - netcoreapp-Debug;netcoreapp-Release - - - - - Common\System\PerfUtils.cs - - - Common\System\Threading\Tasks\Sources\ManualResetValueTaskSource.cs - - - Common\System\Threading\Tasks\Sources\ManualResetValueTaskSourceFactory.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 8b215e1abf2dda075349609425932bb963b6b002 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:07:28 +0100 Subject: [PATCH 34/45] remove System.Security.Cryptography.Primitives.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/0d8fe30d14ddf9fbb1c31f6a9f2fbbdb1c4b27fe --- ...ystem.Security.Cryptography.Primitives.sln | 10 -- .../tests/Performance/Configurations.props | 7 -- .../tests/Performance/Perf.FixedTimeEquals.cs | 115 ------------------ ...ography.Primitives.PerformanceTests.csproj | 22 ---- 4 files changed, 154 deletions(-) delete mode 100644 src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Configurations.props delete mode 100644 src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Perf.FixedTimeEquals.cs delete mode 100644 src/libraries/System.Security.Cryptography.Primitives/tests/Performance/System.Security.Cryptography.Primitives.PerformanceTests.csproj diff --git a/src/libraries/System.Security.Cryptography.Primitives/System.Security.Cryptography.Primitives.sln b/src/libraries/System.Security.Cryptography.Primitives/System.Security.Cryptography.Primitives.sln index 8b0127d7eb2c0..7352af9ca4c4c 100644 --- a/src/libraries/System.Security.Cryptography.Primitives/System.Security.Cryptography.Primitives.sln +++ b/src/libraries/System.Security.Cryptography.Primitives/System.Security.Cryptography.Primitives.sln @@ -7,11 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptograph {DF73E985-E143-4BF5-9FA4-E199E7D36235} = {DF73E985-E143-4BF5-9FA4-E199E7D36235} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Primitives.PerformanceTests", "tests\Performance\System.Security.Cryptography.Primitives.PerformanceTests.csproj", "{FB3EA273-567D-414F-B36D-3698BE8D198B}" - ProjectSection(ProjectDependencies) = postProject - {DF73E985-E143-4BF5-9FA4-E199E7D36235} = {DF73E985-E143-4BF5-9FA4-E199E7D36235} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Security.Cryptography.Primitives", "src\System.Security.Cryptography.Primitives.csproj", "{DF73E985-E143-4BF5-9FA4-E199E7D36235}" ProjectSection(ProjectDependencies) = postProject {F050C895-297F-41C6-98C3-406D791AD515} = {F050C895-297F-41C6-98C3-406D791AD515} @@ -35,10 +30,6 @@ Global {101EB757-55A4-4F48-841C-C088640B8F57}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {101EB757-55A4-4F48-841C-C088640B8F57}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU {101EB757-55A4-4F48-841C-C088640B8F57}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU - {FB3EA273-567D-414F-B36D-3698BE8D198B}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU - {FB3EA273-567D-414F-B36D-3698BE8D198B}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU - {FB3EA273-567D-414F-B36D-3698BE8D198B}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU - {FB3EA273-567D-414F-B36D-3698BE8D198B}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU {DF73E985-E143-4BF5-9FA4-E199E7D36235}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU {DF73E985-E143-4BF5-9FA4-E199E7D36235}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU {DF73E985-E143-4BF5-9FA4-E199E7D36235}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU @@ -53,7 +44,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {101EB757-55A4-4F48-841C-C088640B8F57} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {FB3EA273-567D-414F-B36D-3698BE8D198B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {DF73E985-E143-4BF5-9FA4-E199E7D36235} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD} {F050C895-297F-41C6-98C3-406D791AD515} = {2E666815-2EDB-464B-9DF6-380BF4789AD4} EndGlobalSection diff --git a/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Configurations.props b/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Configurations.props deleted file mode 100644 index a1eadd7648d83..0000000000000 --- a/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netcoreapp; - - - diff --git a/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Perf.FixedTimeEquals.cs b/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Perf.FixedTimeEquals.cs deleted file mode 100644 index d7fbf81eafd48..0000000000000 --- a/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/Perf.FixedTimeEquals.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Xunit.Performance; -using Test.Cryptography; -using Xunit; - -namespace System.Security.Cryptography.Primitives.Tests.Performance -{ - public class Perf_FixedTimeEquals - { - private const int IterationCountFor256Bit = 300000; - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_Equal() - { - MeasureFixedTimeEquals( - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336", - "0000000000000000000000000000000000000000000000000000000000000000"); - } - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_LastBitDifferent() - { - MeasureFixedTimeEquals( - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336", - "0000000000000000000000000000000000000000000000000000000000000001"); - } - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_FirstBitDifferent() - { - MeasureFixedTimeEquals( - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336", - "8000000000000000000000000000000000000000000000000000000000000000"); - } - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_CascadingErrors() - { - MeasureFixedTimeEquals( - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336", - "0102040810204080112244880000000000000000000000000000000000000000"); - } - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_AllBitsDifferent() - { - MeasureFixedTimeEquals( - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336", - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - } - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_VersusZero() - { - MeasureFixedTimeEquals( - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336", - "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336"); - } - - [Benchmark(InnerIterationCount = IterationCountFor256Bit)] - public static void FixedTimeEquals_256Bit_SameReference() - { - byte[] test = "741202531e19d673ad7fff334594549e7c81a285dd02865ddd12530612a96336".HexToByteArray(); - - Span left = test; - Span right = test; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - CryptographicOperations.FixedTimeEquals(left, right); - } - } - } - } - - // The important statistics from these perf runs aren't the mean, but the t-test for - // every set of the same length being the same as when it was equal. - private static void MeasureFixedTimeEquals(string baseValueHex, string errorVectorHex) - { - if (errorVectorHex.Length != baseValueHex.Length) - { - throw new InvalidOperationException(); - } - - byte[] a = baseValueHex.HexToByteArray(); - byte[] b = errorVectorHex.HexToByteArray(); - - for (int i = 0; i < a.Length; i++) - { - b[i] ^= a[i]; - } - - Span left = a; - Span right = b; - - foreach (BenchmarkIteration iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - CryptographicOperations.FixedTimeEquals(left, right); - } - } - } - } - } -} diff --git a/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/System.Security.Cryptography.Primitives.PerformanceTests.csproj b/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/System.Security.Cryptography.Primitives.PerformanceTests.csproj deleted file mode 100644 index 00b9940719ad5..0000000000000 --- a/src/libraries/System.Security.Cryptography.Primitives/tests/Performance/System.Security.Cryptography.Primitives.PerformanceTests.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - {FB3EA273-567D-414F-B36D-3698BE8D198B} - netcoreapp-Debug;netcoreapp-Release - - - - - Common\System\PerfUtils.cs - - - CommonTest\System\Security\Cryptography\ByteUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 8f99ff9bf72b034a9b6f1037ba17c0fa29b0390e Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:09:35 +0100 Subject: [PATCH 35/45] remove System.Xml.XmlDocument.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/2f6859383fb9cd1cccc38a596072f8f20f07a3dc --- .../System.Private.Xml/System.Private.Xml.sln | 10 --- .../Performance/Configurations.props | 7 --- .../Performance/Perf.XmlDocument.cs | 63 ------------------- .../XmlDocument/Performance/Perf.XmlNode.cs | 61 ------------------ .../Performance/Perf.XmlNodeList.cs | 52 --------------- ...em.Xml.XmlDocument.PerformanceTests.csproj | 26 -------- 6 files changed, 219 deletions(-) delete mode 100644 src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Configurations.props delete mode 100644 src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlDocument.cs delete mode 100644 src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNode.cs delete mode 100644 src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNodeList.cs delete mode 100644 src/libraries/System.Private.Xml/tests/XmlDocument/Performance/System.Xml.XmlDocument.PerformanceTests.csproj diff --git a/src/libraries/System.Private.Xml/System.Private.Xml.sln b/src/libraries/System.Private.Xml/System.Private.Xml.sln index 850ee7672ef86..5270d5d523c9b 100644 --- a/src/libraries/System.Private.Xml/System.Private.Xml.sln +++ b/src/libraries/System.Private.Xml/System.Private.Xml.sln @@ -57,11 +57,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.RW.XmlConvert.Te {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} = {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlDocument.PerformanceTests", "tests\XmlDocument\Performance\System.Xml.XmlDocument.PerformanceTests.csproj", "{8A7370E5-BF89-4BCF-ACCD-BA298869055B}" - ProjectSection(ProjectDependencies) = postProject - {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} = {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlDocument.Tests", "tests\XmlDocument\System.Xml.XmlDocument.Tests.csproj", "{7EAFC2D8-48D2-4A56-A9C6-6BADF2053499}" ProjectSection(ProjectDependencies) = postProject {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} = {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} @@ -208,10 +203,6 @@ Global {3F18D20D-0267-4381-857B-EEDB7B3FC549}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {3F18D20D-0267-4381-857B-EEDB7B3FC549}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {3F18D20D-0267-4381-857B-EEDB7B3FC549}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {8A7370E5-BF89-4BCF-ACCD-BA298869055B}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {8A7370E5-BF89-4BCF-ACCD-BA298869055B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {8A7370E5-BF89-4BCF-ACCD-BA298869055B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {8A7370E5-BF89-4BCF-ACCD-BA298869055B}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {7EAFC2D8-48D2-4A56-A9C6-6BADF2053499}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU {7EAFC2D8-48D2-4A56-A9C6-6BADF2053499}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {7EAFC2D8-48D2-4A56-A9C6-6BADF2053499}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU @@ -304,7 +295,6 @@ Global {95C95878-A9CD-43D4-B1BB-D0DCAA54C3D7} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {E6DAD59F-7CB7-4E70-B4C5-FCCBC3376EDE} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {3F18D20D-0267-4381-857B-EEDB7B3FC549} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {8A7370E5-BF89-4BCF-ACCD-BA298869055B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {7EAFC2D8-48D2-4A56-A9C6-6BADF2053499} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {6C6F323D-054E-4723-9DEA-1C5E1E45DF88} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {DA6A9B7F-F311-49A4-8BBE-42EF3152C37B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Configurations.props b/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlDocument.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlDocument.cs deleted file mode 100644 index 577d0a72b504c..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlDocument.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Xml; -using Microsoft.Xunit.Performance; - -namespace XmlDocumentTests.XmlDocumentTests -{ - public class Perf_XmlDocument - { - private const int innerIterations = 10000; - - [Benchmark] - public void Create() - { - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - new XmlDocument(); new XmlDocument(); new XmlDocument(); - new XmlDocument(); new XmlDocument(); new XmlDocument(); - new XmlDocument(); new XmlDocument(); new XmlDocument(); - } - } - } - } - - [Benchmark] - public void LoadXml() - { - XmlDocument doc = new XmlDocument(); - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - doc.LoadXml(" text node two e1; text node three "); - } - - [Benchmark] - public void GetDocumentElement() - { - XmlNode element; - XmlDocument doc = new XmlDocument(); - doc.LoadXml(" text node two e1; text node three "); - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - element = doc.DocumentElement; element = doc.DocumentElement; element = doc.DocumentElement; - element = doc.DocumentElement; element = doc.DocumentElement; element = doc.DocumentElement; - element = doc.DocumentElement; element = doc.DocumentElement; element = doc.DocumentElement; - } - } - } - } - } -} diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNode.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNode.cs deleted file mode 100644 index 78e392b05e5a6..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNode.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Xml; -using Microsoft.Xunit.Performance; - -namespace XmlDocumentTests.XmlNodeTests -{ - public class Perf_XmlNode - { - private const int innerIterations = 10000; - - [Benchmark] - public void GetAttributes() - { - // Setup - XmlAttributeCollection attr; - XmlDocument doc = new XmlDocument(); - doc.LoadXml(""); - XmlNode node = doc.DocumentElement; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - attr = node.Attributes; attr = node.Attributes; attr = node.Attributes; - attr = node.Attributes; attr = node.Attributes; attr = node.Attributes; - attr = node.Attributes; attr = node.Attributes; attr = node.Attributes; - } - } - } - } - - [Benchmark] - public void GetValue() - { - // Setup - string value; - var doc = new XmlDocument(); - doc.LoadXml(""); - XmlNode node = doc.DocumentElement; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - value = node.Value; value = node.Value; value = node.Value; - value = node.Value; value = node.Value; value = node.Value; - value = node.Value; value = node.Value; value = node.Value; - } - } - } - } - } -} diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNodeList.cs b/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNodeList.cs deleted file mode 100644 index 9abaa7531640d..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/Perf.XmlNodeList.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Xml; -using Microsoft.Xunit.Performance; - -namespace XmlDocumentTests.XmlNodeListTests -{ - public class Perf_XmlNodeList - { - private const int innerIterations = 10000; - - [Benchmark] - public void Enumerator() - { - // Setup - var doc = new XmlDocument(); - doc.LoadXml(""); - XmlNodeList list = doc.DocumentElement.ChildNodes; - - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < innerIterations; i++) - foreach (var element in list) { } - } - - [Benchmark] - public void GetCount() - { - // Setup - var doc = new XmlDocument(); - doc.LoadXml(""); - XmlNodeList list = doc.DocumentElement.ChildNodes; - int count; - - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < innerIterations; i++) - { - count = list.Count; count = list.Count; count = list.Count; - count = list.Count; count = list.Count; count = list.Count; - count = list.Count; count = list.Count; count = list.Count; - } - } - } - } - } -} diff --git a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/System.Xml.XmlDocument.PerformanceTests.csproj b/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/System.Xml.XmlDocument.PerformanceTests.csproj deleted file mode 100644 index 6d6be6f90eeae..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlDocument/Performance/System.Xml.XmlDocument.PerformanceTests.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - {8A7370E5-BF89-4BCF-ACCD-BA298869055B} - netstandard-Debug;netstandard-Release - - - - - - - - Common\System\PerfUtils.cs - - - - - PreserveNewest - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file From 60cedf8094db41046631c8f8c278a3d9a341be40 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:11:56 +0100 Subject: [PATCH 36/45] remove System.Xml.XmlSerializer.PerformanceTests Commit migrated from https://github.com/dotnet/corefx/commit/0fd81f961eae20d564437cd096d483a79a81239f --- .../System.Private.Xml/System.Private.Xml.sln | 10 -- .../Performance/Configurations.props | 7 -- ....Xml.XmlSerializer.PerformanceTests.csproj | 19 ---- .../Performance/XsPerformanceTest.cs | 106 ------------------ 4 files changed, 142 deletions(-) delete mode 100644 src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/Configurations.props delete mode 100644 src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/System.Xml.XmlSerializer.PerformanceTests.csproj delete mode 100644 src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/XsPerformanceTest.cs diff --git a/src/libraries/System.Private.Xml/System.Private.Xml.sln b/src/libraries/System.Private.Xml/System.Private.Xml.sln index 5270d5d523c9b..c6394053fa077 100644 --- a/src/libraries/System.Private.Xml/System.Private.Xml.sln +++ b/src/libraries/System.Private.Xml/System.Private.Xml.sln @@ -102,11 +102,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSchema.XmlSch {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} = {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSerializer.PerformanceTests", "tests\XmlSerializer\Performance\System.Xml.XmlSerializer.PerformanceTests.csproj", "{9891F9AC-9A0A-47DF-8D96-92B21AFC3B93}" - ProjectSection(ProjectDependencies) = postProject - {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} = {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xml.XmlSerializer.ReflectionOnly.Tests", "tests\XmlSerializer\ReflectionOnly\System.Xml.XmlSerializer.ReflectionOnly.Tests.csproj", "{4050F1D1-1DD2-4B48-A17B-E3F955518C4B}" ProjectSection(ProjectDependencies) = postProject {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} = {C427CE0D-0740-41F3-9C3A-552BEA3DDB0D} @@ -239,10 +234,6 @@ Global {B0F53AAA-4ABC-44B2-9331-D3802340DD20}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {B0F53AAA-4ABC-44B2-9331-D3802340DD20}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU {B0F53AAA-4ABC-44B2-9331-D3802340DD20}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU - {9891F9AC-9A0A-47DF-8D96-92B21AFC3B93}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU - {9891F9AC-9A0A-47DF-8D96-92B21AFC3B93}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU - {9891F9AC-9A0A-47DF-8D96-92B21AFC3B93}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU - {9891F9AC-9A0A-47DF-8D96-92B21AFC3B93}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU {4050F1D1-1DD2-4B48-A17B-E3F955518C4B}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU {4050F1D1-1DD2-4B48-A17B-E3F955518C4B}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU {4050F1D1-1DD2-4B48-A17B-E3F955518C4B}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU @@ -304,7 +295,6 @@ Global {F011A6F5-BA48-4F8D-A20F-79CCE01CDE0E} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {9EDAADA8-B658-430F-97EE-CCA494883D86} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {B0F53AAA-4ABC-44B2-9331-D3802340DD20} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} - {9891F9AC-9A0A-47DF-8D96-92B21AFC3B93} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {4050F1D1-1DD2-4B48-A17B-E3F955518C4B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {4050F1D1-1DD2-4B48-A17B-E3F90DD18C4B} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} {8CDE71C2-4DA4-4AF6-9897-CD953AE653C2} = {1A2F9F4A-A032-433E-B914-ADD5992BB178} diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/Configurations.props b/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/System.Xml.XmlSerializer.PerformanceTests.csproj b/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/System.Xml.XmlSerializer.PerformanceTests.csproj deleted file mode 100644 index 185100261990e..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/System.Xml.XmlSerializer.PerformanceTests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - {9891F9AC-9A0A-47DF-8D96-92B21AFC3B93} - netstandard-Debug;netstandard-Release - - - - - - - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/XsPerformanceTest.cs b/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/XsPerformanceTest.cs deleted file mode 100644 index 018d552347e56..0000000000000 --- a/src/libraries/System.Private.Xml/tests/XmlSerializer/Performance/XsPerformanceTest.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Runtime.Serialization; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System.Xml.XmlSerializer.Tests.Performance -{ - #region XmlSerializer performance tests - - public class XsPerformanceTest - { -#if ReflectionOnly - private static readonly string SerializationModeSetterName = "set_Mode"; - - static XsPerformanceTest() - { - if (!PlatformDetection.IsFullFramework) - { - MethodInfo method = typeof(Serialization.XmlSerializer).GetMethod(SerializationModeSetterName, BindingFlags.NonPublic | BindingFlags.Static); - Assert.True(method != null, $"No method named {SerializationModeSetterName}"); - method.Invoke(null, new object[] { 1 }); - } - } -#endif - - public static IEnumerable SerializeMemberData() - { - foreach (PerfTestConfig config in PerformanceTestCommon.PerformanceTestConfigurations()) - { - // XmlSerializer doesn't support Dictionary type - if (config.PerfTestType == TestType.Dictionary - || config.PerfTestType == TestType.DictionaryOfSimpleType) - { - continue; - } - - yield return config.ToObjectArray(); - } - } - - [Benchmark] - [MemberData(nameof(SerializeMemberData))] - public void XsSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunSerializationPerformanceTest(numberOfRuns, testType, testSize, XsSerializerFactory.GetInstance()); - } - - [Benchmark] - [MemberData(nameof(SerializeMemberData))] - public void XsDeSerializationTest(int numberOfRuns, TestType testType, int testSize) - { - PerformanceTestCommon.RunDeserializationPerformanceTest(numberOfRuns, testType, testSize, XsSerializerFactory.GetInstance()); - } - } - - #endregion - - #region XmlSerializer wrapper - - internal class XsSerializerFactory : ISerializerFactory - { - private static readonly XsSerializerFactory s_instance = new XsSerializerFactory(); - public static XsSerializerFactory GetInstance() - { - return s_instance; - } - - public IPerfTestSerializer GetSerializer() - { - return new XsSerializer(); - } - } - - internal class XsSerializer : IPerfTestSerializer - { - private Serialization.XmlSerializer _serializer; - - public void Deserialize(Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - _serializer.Deserialize(stream); - } - - public void Init(object obj) - { - _serializer = new Serialization.XmlSerializer(obj.GetType()); - } - - public void Serialize(object obj, Stream stream) - { - Debug.Assert(_serializer != null); - Debug.Assert(stream != null); - _serializer.Serialize(stream, obj); - } - } - - #endregion -} From 212d08feafbdaaef3fb6bef9f7f8f185ddb8eee8 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:13:45 +0100 Subject: [PATCH 37/45] remove Marvin Commit migrated from https://github.com/dotnet/corefx/commit/6c34b5fd6670ef80900dfc54e9c5facfd348df5b --- .../Common/tests/Performance/Perf.Marvin.cs | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/libraries/Common/tests/Performance/Perf.Marvin.cs diff --git a/src/libraries/Common/tests/Performance/Perf.Marvin.cs b/src/libraries/Common/tests/Performance/Perf.Marvin.cs deleted file mode 100644 index 8f6e45f41e445..0000000000000 --- a/src/libraries/Common/tests/Performance/Perf.Marvin.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xunit.Performance; -using Xunit; - -namespace System -{ - public class Perf_Marvin - { - private static IEnumerable EnumerateRandomByteArrayTestCases() - { - var r = new Random(123); - foreach (int size in - Enumerable.Range(0, 25) - .Union(new int[] { 50, 100, 200, 2000, 20000, 200000, 2000000 })) - { - byte[] array = new byte[size]; - r.NextBytes(array); - - int iterations = 2000000 / Math.Max(1, size); - yield return new object[] { iterations, array }; - } - } - - [Benchmark] - [MemberData(nameof(EnumerateRandomByteArrayTestCases))] - public void Add(int iterations, byte[] data) - { - ReadOnlySpan otherData = new byte[] { 1, 2, 3 }; - var bytes = new ReadOnlySpan(data); - foreach (var iteration in Benchmark.Iterations) - { - using (iteration.StartMeasurement()) - { - for (int i = 0; i < iterations; i++) - { - Marvin.ComputeHash(bytes, 123123123123UL); - Marvin.ComputeHash(otherData, 555888555888UL); - } - } - } - } - } -} From ab6230cf1b969e0eda281e9965f803db445ddbea Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:14:20 +0100 Subject: [PATCH 38/45] remove PerfRunner Commit migrated from https://github.com/dotnet/corefx/commit/643df81e92d4502075235e8c27a4b50ff8a6973a --- .../tests/Performance/BenchmarkFilter.cs | 76 ------------------- .../Common.PerformanceTests.csproj | 22 ------ .../tests/Performance/Configurations.props | 7 -- .../PerfRunner/AssemblyAttributes.cs | 5 -- .../PerfRunner/Configurations.props | 7 -- .../Performance/PerfRunner/PerfRunner.cs | 46 ----------- .../Performance/PerfRunner/PerfRunner.csproj | 20 ----- 7 files changed, 183 deletions(-) delete mode 100644 src/libraries/Common/tests/Performance/BenchmarkFilter.cs delete mode 100644 src/libraries/Common/tests/Performance/Common.PerformanceTests.csproj delete mode 100644 src/libraries/Common/tests/Performance/Configurations.props delete mode 100644 src/libraries/Common/tests/Performance/PerfRunner/AssemblyAttributes.cs delete mode 100644 src/libraries/Common/tests/Performance/PerfRunner/Configurations.props delete mode 100644 src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.cs delete mode 100644 src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.csproj diff --git a/src/libraries/Common/tests/Performance/BenchmarkFilter.cs b/src/libraries/Common/tests/Performance/BenchmarkFilter.cs deleted file mode 100644 index 988ed2022c866..0000000000000 --- a/src/libraries/Common/tests/Performance/BenchmarkFilter.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Reflection; -using Xunit.Abstractions; -using Xunit.Sdk; - -// Usage: [assembly: TestCaseOrderer("Microsoft.DotNet.XUnitExtensions.BenchmarkFilter", "System.Drawing.Common.PerformanceTests")] - -namespace Microsoft.DotNet.XUnitExtensions -{ - public class BenchmarkFilter : ITestCaseOrderer - { - private static MethodInfo LookupConditionalMethod(Type t, string name) - { - if (t == null || name == null) - return null; - - TypeInfo ti = t.GetTypeInfo(); - - MethodInfo mi = ti.GetDeclaredMethod(name); - if (mi != null && mi.IsStatic && mi.GetParameters().Length == 0 && mi.ReturnType == typeof(bool)) - return mi; - - PropertyInfo pi = ti.GetDeclaredProperty(name); - if (pi != null && pi.PropertyType == typeof(bool) && pi.GetMethod != null && pi.GetMethod.IsStatic && pi.GetMethod.GetParameters().Length == 0) - return pi.GetMethod; - - return LookupConditionalMethod(ti.BaseType, name); - } - - public IEnumerable OrderTestCases(IEnumerable testCases) - where TTestCase : ITestCase - { - foreach (TTestCase testCase in testCases) - { - bool success = true; - - IEnumerable attributes = testCase.TestMethod.Method.GetCustomAttributes(typeof(ConditionalBenchmarkAttribute).AssemblyQualifiedName); - foreach (IAttributeInfo attributeInfo in attributes) - { - Type calleeType = attributeInfo.GetNamedArgument("CalleeType"); - string[] conditionMemberNames = attributeInfo.GetNamedArgument("ConditionMemberNames"); - foreach (string conditionMemberName in conditionMemberNames) - { - MethodInfo conditionMethodInfo = LookupConditionalMethod(calleeType, conditionMemberName); - if (conditionMethodInfo == null) - throw new Exception($"Conditional method with name '{conditionMemberName}' not found"); - - if (!(bool)conditionMethodInfo.Invoke(null, null)) - success = false; - } - } - - if (success) - yield return testCase; - } - } - } - - public class ConditionalBenchmarkAttribute : Attribute - { - public ConditionalBenchmarkAttribute(Type calleeType, params string[] conditionMemberNames) - { - CalleeType = calleeType; - ConditionMemberNames = conditionMemberNames; - } - - public Type CalleeType { get; } - - public string[] ConditionMemberNames { get; } - } -} diff --git a/src/libraries/Common/tests/Performance/Common.PerformanceTests.csproj b/src/libraries/Common/tests/Performance/Common.PerformanceTests.csproj deleted file mode 100644 index 68d4c3066607f..0000000000000 --- a/src/libraries/Common/tests/Performance/Common.PerformanceTests.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - {B96198F5-9BF7-42DE-83E8-3EE39DA25F43} - true - netstandard-Debug;netstandard-Release - - - - Common\System\Marvin.cs - - - - Common\System\PerfUtils.cs - - - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - - \ No newline at end of file diff --git a/src/libraries/Common/tests/Performance/Configurations.props b/src/libraries/Common/tests/Performance/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/Common/tests/Performance/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/Common/tests/Performance/PerfRunner/AssemblyAttributes.cs b/src/libraries/Common/tests/Performance/PerfRunner/AssemblyAttributes.cs deleted file mode 100644 index 42582dccfb0fa..0000000000000 --- a/src/libraries/Common/tests/Performance/PerfRunner/AssemblyAttributes.cs +++ /dev/null @@ -1,5 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] diff --git a/src/libraries/Common/tests/Performance/PerfRunner/Configurations.props b/src/libraries/Common/tests/Performance/PerfRunner/Configurations.props deleted file mode 100644 index 581054d46db4b..0000000000000 --- a/src/libraries/Common/tests/Performance/PerfRunner/Configurations.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - netstandard; - - - \ No newline at end of file diff --git a/src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.cs b/src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.cs deleted file mode 100644 index 4b75d1e59d839..0000000000000 --- a/src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Reflection; -using System.Collections.Generic; -using Microsoft.Xunit.Performance.Api; - -public class PerfHarness -{ - public static int Main(string[] args) - { - try - { - using (XunitPerformanceHarness harness = new XunitPerformanceHarness(args)) - { - foreach(var testName in GetTestAssemblies()) - { - harness.RunBenchmarks(GetTestAssembly(testName)); - } - } - - return 0; - } - catch (Exception ex) - { - Console.WriteLine("[ERROR] Benchmark execution failed."); - Console.WriteLine($" {ex.ToString()}"); - return 1; - } - } - - private static string GetTestAssembly(string testName) - { - // Assume test assemblies are colocated/restored next to the PerfHarness. - return Path.Combine( - Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), testName); - } - - private static IEnumerable GetTestAssemblies() - { - return Directory.EnumerateFiles(".", "*.PerformanceTests.dll"); - } -} diff --git a/src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.csproj b/src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.csproj deleted file mode 100644 index addbf1c2d6a3e..0000000000000 --- a/src/libraries/Common/tests/Performance/PerfRunner/PerfRunner.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - {F5E941C8-AF2F-47AB-A066-FF25470CE382} - Exe - - .exe - true - false - 0436 - true - netstandard-Debug;netstandard-Release - - - - - - Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs - - - \ No newline at end of file From af4b9b9e26b0ffa3eb725331383b5e49fd222230 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:17:09 +0100 Subject: [PATCH 39/45] remove PerfUtils Commit migrated from https://github.com/dotnet/corefx/commit/07ae058f188e21fe78e80d002b086ef8a16cf236 --- .../Common/tests/System/PerfUtils.cs | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 src/libraries/Common/tests/System/PerfUtils.cs diff --git a/src/libraries/Common/tests/System/PerfUtils.cs b/src/libraries/Common/tests/System/PerfUtils.cs deleted file mode 100644 index f205f0bf911de..0000000000000 --- a/src/libraries/Common/tests/System/PerfUtils.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.IO; -using System.Runtime.CompilerServices; - -namespace System -{ - /// Static helper class for performance tests - public class PerfUtils - { - private Random _rand; - - /// - /// Initializes a new PerfUtils object with the default random seed. - /// - public PerfUtils() - { - _rand = new Random(1234132); - } - - /// - /// Initializes a new PerfUtils object with the given seed. Use this if also - /// using MemberData that was created using PerfUtils to avoid possible collision - /// errors. - /// - public PerfUtils(int seed) - { - _rand = new Random(seed); - } - - /// - /// Helper method to create a string containing a number of - /// characters equal to the specified length - /// - public string CreateString(int length) - { - char[] str = new char[length]; - - for (int i = 0; i < str.Length; i++) - { - // Add path separator so folders aren't too long. - if (i % 20 == 0) - { - str[i] = Path.DirectorySeparatorChar; - } - else - { - str[i] = 'a'; - } - } - - return new string(str); - } - - /// Gets a test file full path that is associated with the call site. - /// An optional index value to use as a suffix on the file name. Typically a loop index. - /// The member name of the function calling this method. - /// The line number of the function calling this method. - public string GetTestFilePath(int? index = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int lineNumber = 0) - { - return Path.Combine(Path.GetTempPath(), string.Format( - index.HasValue ? "{0}_{1}_{2}_{3}" : "{0}_{1}_{2}", - memberName ?? "TestBase", lineNumber, Path.GetRandomFileName(), - index.GetValueOrDefault())); - } - } -} From bbd3e63233b61ec2369a7ec12ae11a2a9b908706 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 08:20:28 +0100 Subject: [PATCH 40/45] remove the dependency to xunit-performance Commit migrated from https://github.com/dotnet/corefx/commit/36fec21ff3faa72480132c1e0fb3d022531f84f7 --- .../test-runtime/XUnit.Runtime.depproj | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/libraries/external/test-runtime/XUnit.Runtime.depproj b/src/libraries/external/test-runtime/XUnit.Runtime.depproj index 02256e1073be3..f1fb058ff086f 100644 --- a/src/libraries/external/test-runtime/XUnit.Runtime.depproj +++ b/src/libraries/external/test-runtime/XUnit.Runtime.depproj @@ -62,25 +62,6 @@ - - - - - - - - - - - - - - - - - - - From 2f6af396baab78ec13a8774594ed7bec64cb0ecf Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 10:48:36 +0100 Subject: [PATCH 41/45] the ManualPerformanceTests don't really need or use PerfRunner.csproj Commit migrated from https://github.com/dotnet/corefx/commit/61d72ec21d038134a00241db60f1dd6c8934cb3f --- .../System.Net.Sockets.Async.PerformanceTests.csproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.PerformanceTests.csproj b/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.PerformanceTests.csproj index a66909f181f9d..59f93d477b097 100644 --- a/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.PerformanceTests.csproj +++ b/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.PerformanceTests.csproj @@ -57,10 +57,4 @@ SocketCommon\SocketTestMemcmp.Unix.cs - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - \ No newline at end of file From 5a4644cdcfd4ffecc348f9dcfef90f0159b6dddc Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 11:09:29 +0100 Subject: [PATCH 42/45] TraceEvent dependency is mandatory for the Microsoft.Diagnostics.Tracing tests Commit migrated from https://github.com/dotnet/corefx/commit/e25a7be9c57e82c664c134b3e9678d80de1704fc --- src/libraries/external/test-runtime/XUnit.Runtime.depproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libraries/external/test-runtime/XUnit.Runtime.depproj b/src/libraries/external/test-runtime/XUnit.Runtime.depproj index f1fb058ff086f..985f2d0a98cfe 100644 --- a/src/libraries/external/test-runtime/XUnit.Runtime.depproj +++ b/src/libraries/external/test-runtime/XUnit.Runtime.depproj @@ -62,6 +62,13 @@ + + + + + + + From b39c116016efaf25481dad1414644fa4dae50fdf Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 11:34:14 +0100 Subject: [PATCH 43/45] rename "System.Net.Sockets.Async.PerformanceTests" to "System.Net.Sockets.Async.Stress.Tests" to avoid implicit xunit-performance package dependency Commit migrated from https://github.com/dotnet/corefx/commit/395bfe6b9d87633762fe01f012ff89b5fa52f15c --- ...eTests.csproj => System.Net.Sockets.Async.Stress.Tests.csproj} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/{System.Net.Sockets.Async.PerformanceTests.csproj => System.Net.Sockets.Async.Stress.Tests.csproj} (100%) diff --git a/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.PerformanceTests.csproj b/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.Stress.Tests.csproj similarity index 100% rename from src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.PerformanceTests.csproj rename to src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.Stress.Tests.csproj From 982ec7f2f63263535b9cec9c88ec3c06300e938d Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 5 Mar 2019 17:32:27 +0100 Subject: [PATCH 44/45] remove XunitShowProgress as recommended by Viktor Hofer Commit migrated from https://github.com/dotnet/corefx/commit/6d9411b3e8dd1b9d69dffe988613bf550fac06f4 --- .../System.Net.Sockets.Async.Stress.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.Stress.Tests.csproj b/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.Stress.Tests.csproj index 59f93d477b097..078e91a69cf0c 100644 --- a/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.Stress.Tests.csproj +++ b/src/libraries/System.Net.Sockets/tests/ManualPerformanceTests/System.Net.Sockets.Async.Stress.Tests.csproj @@ -1,6 +1,5 @@ - true {BB5C85AD-C51A-4903-80E9-6F6E1AC1AD34} netstandard-Unix-Debug;netstandard-Unix-Release;netstandard-Windows_NT-Debug;netstandard-Windows_NT-Release From cbb5b9d54bba180bf9a31e672f8893f65718a565 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 20 Mar 2019 20:35:37 +0100 Subject: [PATCH 45/45] update the docs Commit migrated from https://github.com/dotnet/corefx/commit/be8fe7d2402b9f8a8f1a19472d7a36d71296225d --- docs/libraries/project-docs/benchmarking.md | 149 +----------------- .../libraries/project-docs/developer-guide.md | 8 +- .../project-docs/performance-tests.md | 87 +--------- 3 files changed, 11 insertions(+), 233 deletions(-) diff --git a/docs/libraries/project-docs/benchmarking.md b/docs/libraries/project-docs/benchmarking.md index 19f2ab35ac785..a647519d5327e 100644 --- a/docs/libraries/project-docs/benchmarking.md +++ b/docs/libraries/project-docs/benchmarking.md @@ -1,150 +1,5 @@ # Benchmarking .NET Core applications -We recommend using [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) as it allows specifying custom SDK paths and measuring performance not just in-proc but also out-of-proc as a dedicated executable. +All Benchmarks have been moved to the [dotnet/performance/](https://github.com/dotnet/performance/) repository. -``` - - - -``` - -## Defining your benchmark - -See [BenchmarkDotNet](https://benchmarkdotnet.org/articles/guides/getting-started.html) documentation -- minimally you need to adorn a public method with the `[Benchmark]` attribute but there are many other ways to customize what is done such as using parameter sets or setup/cleanup methods. Of course, you'll want to bracket just the relevant code in your benchmark, ensure there are sufficient iterations that you minimise noise, as well as leaving the machine otherwise idle while you measure. - -# Benchmarking local CoreFX builds - -Since `0.11.1` BenchmarkDotNet knows how to run benchmarks with CoreRun. So you just need to provide it the path to CoreRun! The simplest way to do that is via console line arguments: - - dotnet run -c Release -f netcoreapp3.0 -- -f *MyBenchmarkName* --coreRun "C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe" - -**Hint:** If you are curious to know what BDN does internally you just need to apply `[KeepBenchmarkFiles]` attribute to your class or set `KeepBenchmarkFiles = true` in your config file. After running the benchmarks you can find the auto-generated files in `%pathToBenchmarkApp\bin\Release\$TFM\` folder. - -The alternative is to use `CoreRunToolchain` from code level: - -```cs -class Program -{ - static void Main(string[] args) - => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly) - .Run(args, DefaultConfig.Instance.With( - Job.ShortRun.With( - new CoreRunToolchain( - new FileInfo(@"C:\Projects\corefx\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe") - )))); -} -``` - - -**Warning:** To fully understand the results you need to know what optimizations (PGO, CrossGen) were applied to given build. Usually, CoreCLR installed with the .NET Core SDK will be fully optimized and the fastest. On Windows, you can use the [disassembly diagnoser](http://adamsitnik.com/Disassembly-Diagnoser/) to check the produced assembly code. - -## New API - -If you are testing some new APIs you need to tell BenchmarkDotNet where is `dotnet cli` that is capable of building the code. You can do that by using the `--cli` command line argument. - -# Running in process - -If you want to run your benchmarks without spawning a new process per benchmark you can do that by passing `-i` console line argument. Please be advised that using [InProcessToolchain](https://benchmarkdotnet.org/articles/configs/toolchains.html#sample-introinprocess) is not recommended when one of your benchmarks might have side effects which affect other benchmarks. A good example is heavy allocating benchmark which affects the size of GC generations. - - dotnet run -c Release -f netcoreapp2.1 -- -f *MyBenchmarkName* -i - -# Recommended workflow - -1. Before you start benchmarking the code you need to build entire CoreFX in Release which is going to generate the right CoreRun bits for you: - - C:\Projects\corefx>build.cmd -c Release -arch x64 - -After that, you should be able to find `CoreRun.exe` in a location similar to: - - C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe - -2. Create a new .NET Core console app using your favorite IDE -3. Install BenchmarkDotNet (0.11.1+) -4. Define the benchmarks and pass the arguments to BenchmarkSwitcher - -```cs -class Program -{ - static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); -} -``` -5. Run the benchmarks using `--coreRun` from the first step. Save the results in a dedicated folder. - - dotnet run -c Release -f netcoreapp3.0 -- -f * --coreRun "C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe" --artifacts ".\before" - -6. Go to the corresponding CoreFX source folder (for example `corefx\src\System.Collections.Immutable`) -7. Apply the optimization that you want to test -8. Rebuild given CoreFX part in Release: - - dotnet msbuild /p:ConfigurationGroup=Release - -You should notice that given `.dll` file have been updated in the `CoreRun` folder. - -9. Run the benchmarks using `--coreRun` from the first step. Save the results in a dedicated folder. - - dotnet run -c Release -f netcoreapp3.0 -- -f * --coreRun "C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe" --artifacts ".\after" - -10. Compare the results and repeat steps `7 - 9` until you are happy about the results. - -## Benchmarking APIs implemented within System.Private.Corelib - -1. The steps for this scenario are very similar to the above recommended workflow with a couple of extra steps to copy bits from one repo to the other. Before you start benchmarking the code you need to build entire CoreCLR in Release which is going to generate the `System.Private.Corelib.dll` for you: - - C:\Projects\coreclr>build.cmd -release -skiptests - -After that, you should be able to find `System.Private.Corelib.dll` in a location similar to: - - C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release - -2. Build entire CoreFX in Release using your local private build of coreclr (See [Testing With Private CoreCLR Bits](https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md#testing-with-private-coreclr-bits)) - - C:\Projects\corefx>build.cmd -c Release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release - -After that, you should be able to find `CoreRun.exe` in a location similar to: - - C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe - -3. Create a new .NET Core console app using your favorite IDE -4. Install BenchmarkDotNet (0.11.1+) -5. Define the benchmarks and pass the arguments to BenchmarkSwitcher - -```cs -class Program -{ - static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); -} -``` -6. Run the benchmarks using `--coreRun` from the second step. Save the results in a dedicated folder. - - dotnet run -c Release -f netcoreapp3.0 -- -f * --coreRun "C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe" --artifacts ".\before" - -7. Go to the corresponding CoreCLR source folder where the API you want to change exists (for example `coreclr\src\System.Private.CoreLib\shared\System`) -8. Apply the optimization that you want to test -9. Rebuild System.Private.Corelib with your change (optionally adding `-skipnative` if the change is isolated to managed code): - - C:\Projects\coreclr>build.cmd -release -skiptests -skipnative -skipbuildpackages - -10. For the next step, you have one of two options: - - - Rebuild given CoreFX part in Release: - - C:\Projects\corefx>build.cmd -c Release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release - - - Force refresh of CoreCLR hard-link copy (this ends up being much faster than the first option): - - C:\Projects\corefx>build.cmd -restore -c Release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release - -11. Run the benchmarks using `--coreRun` from the first step. Save the results in a dedicated folder. - - dotnet run -c Release -f netcoreapp3.0 -- -f * --coreRun "C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe" --artifacts ".\after" - -12. Compare the results and repeat steps `8 - 11` until you are happy about the results. - -# Reporting results - -Often in a Github Pull Request or issue you will want to share performance results to justify a change. If you add the `MarkdownExporter` job in the configuration (as you can see in Alternative 3), BenchmarkDotNet will have created a Markdown (*.md) file in the `BenchmarkDotNet.Artifacts` folder which you can paste in, along with the code you benchmarked. - -# References -- [BenchmarkDotNet](http://benchmarkdotnet.org/) -- [BenchmarkDotNet Github](https://github.com/dotnet/BenchmarkDotNet) -- [.NET Core SDK](https://github.com/dotnet/core-setup) +Please read the [Benchmarking workflow for CoreFX](https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-corefx.md) document to find out how to build and run the Benchmarks. \ No newline at end of file diff --git a/docs/libraries/project-docs/developer-guide.md b/docs/libraries/project-docs/developer-guide.md index 8fc8d6b8fe3bf..febf112fca1ca 100644 --- a/docs/libraries/project-docs/developer-guide.md +++ b/docs/libraries/project-docs/developer-guide.md @@ -44,7 +44,7 @@ For more details on the build configurations see [project-guidelines](../coding- The most common workflow for developers is to call `build` from the root once and then go and work on the individual library that you are trying to make changes for. -By default build only builds the product libraries and none of the tests. If you want to build the tests you can call `build -buildtests`. If you want to run the tests you can call `build -test` or `build -performanceTest`. To build and run the tests combine both arguments: `build -buildtests -test`. To build both the product libraries and the test libraries pass `build -build -buildtests` to the command line. If you want to further configure which test libraries to build you can pass `/p:TestProjectFilter=Tests|PerformanceTests` to the command. +By default build only builds the product libraries and none of the tests. If you want to build the tests you can call `build -buildtests`. If you want to run the tests you can call `build -test`. To build and run the tests combine both arguments: `build -buildtests -test`. To build both the product libraries and the test libraries pass `build -build -buildtests` to the command line. If you invoke the build script without any argument the default arguments will be executed `-restore -build`. Note that -restore and -build are only implicit if no actions are passed in. @@ -206,6 +206,12 @@ One can build in Debug or Release mode from the root by doing `build -c Release` One can build 32- or 64-bit binaries or for any architecture by specifying in the root `build -arch [value]` or in a project `/p:ArchGroup=[value]` after the `dotnet msbuild` command. +### Benchmarks + +All Benchmarks have been moved to the [dotnet/performance/](https://github.com/dotnet/performance/) repository. + +Please read the [Benchmarking workflow for CoreFX](https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-corefx.md) document to find out how to build and run the Benchmarks. + ### Tests We use the OSS testing framework [xunit](http://xunit.github.io/). diff --git a/docs/libraries/project-docs/performance-tests.md b/docs/libraries/project-docs/performance-tests.md index 3f3afb2248ffa..fa9f9ccd2ea2b 100644 --- a/docs/libraries/project-docs/performance-tests.md +++ b/docs/libraries/project-docs/performance-tests.md @@ -1,89 +1,6 @@ Performance Tests ====================== -This document contains instructions for building, running, and adding Performance tests. +All Performance Tests have been moved to the [dotnet/performance/](https://github.com/dotnet/performance/) repository. -Building and Running Tests ------------ -Performance test files (if present) are stored within a library's ```tests/Performance``` directory and contain test methods that are all marked with a perf-specific *Benchmark* attribute. - -**Step # 1:** Prior to running performance tests, a full build from the repo root must be completed: `build -c Release` - -**Step # 2:** Change directory to the performance tests directory: ```cd path/to/library/tests/Performance``` - -**Step # 3:** Build and run the tests: - - Windows ```dotnet msbuild /t:BuildAndPerformanceTest /p:ConfigurationGroup=Release``` - - Linux: ```dotnet msbuild /t:BuildAndPerformanceTest /p:ConfigurationGroup=Release``` - -The results files will be dropped in corefx/artifacts/bin/tests/TESTLIBRARY/FLAVOR/. The console output will also specify the location of these files. - -To build and run all tests from root, execute the following command: `build -performanceTest -buildtests -c Release`. - -**Getting memory usage** - -To see memory usage as well as time, add the following property to the command lines above: `/p:CollectFlags=stopwatch+gcapi`. - -Adding New Performance Tests ------------ -Performance tests for CoreFX are built on top of xunit and [the Microsoft xunit-performance framework](https://github.com/Microsoft/xunit-performance/). - -Performance tests should reside within their own "Performance" folder within the tests directory of a library (e.g. [corefx/src/System.IO.FileSystem/tests/Performance](https://github.com/dotnet/corefx/tree/master/src/System.IO.FileSystem/tests/Performance) contains perf tests for FileSystem). - -It's easiest to copy and modify an existing example like the one above. Notice that you'll need these lines in the tests csproj: -``` - - - {69e46a6f-9966-45a5-8945-2559fe337827} - PerfRunner - - -``` -Once that’s all done, you can actually add tests to the file. - -Writing Test Cases ------------ -```C# -using Xunit; -using Microsoft.Xunit.Performance; - -namespace System.Collections.Tests -{ - public class Perf_Dictionary - { - private volatile Dictionary dict; - - [Benchmark(InnerIterationCount = 2000)] - public void ctor() - { - foreach (var iteration in Benchmark.Iterations) - using (iteration.StartMeasurement()) - for (int i = 0; i < Benchmark.InnerIterationCount; i++) - { - dict = new Dictionary(); - } - } - } -} -``` - -The above benchmark will test the performance of the Dictionary constructor. Each iteration of the benchmark will call the constructor 2000 times (`InnerIterationCount`). - -Test cases should adhere to the following guidelines, within reason: - -* Individual test cases should be of the "microbenchmark" variety. They should test a single function, in as isolated an environment as possible. -* The "real work" must be done inside of the `using (iteration.StartMeasurement())` block. All extra work (setup, cleanup) should be done outside of this block, so as to not pollute the data being collected. -* Individual iterations of a test case should take from 100 milliseconds to 1 second. This is everything inside of the `using (iteration.StartMeasurement())` block. -* Test cases may need to use an "inner iteration" concept in order for individual invocations of the "outer iteration" to last from 100 ms to 1s. The example above shows this. -* Some functions are prone to being entirely optimized out from test cases. For example, if the results of `Vector3.Add()` are not stored anywhere, then there are no observable side-effects, and the entire operation can be optimized out by the JIT. For operations which are susceptible to this, care must be taken to ensure that the operations are not entirely skipped. Try the following: - * Pass intermediate values to a volatile static field. This is done in the example code above. - * If the value is a struct, compute a value dependent on the structure, and store that in a volatile static field. -* There are two main ways to detect when a test case is being "optimized out": - * Look at the disassembly of the function (with the Visual Studio disassembler, for example). - * Observe unusual changes in the duration metric. If your test suddenly takes 1% of its previous time, odds are something has gone wrong. -* Before using intrinsic data types (int, string, etc) to represent value and reference types in your test, consider if the code under test is optimized for those types versus normal classes and structs. - * Also consider interfaces. For example, methods on ```List``` using equality will be much faster on Ts that implement ```IEquatable```. - -Avoid the following performance test test anti-patterns: -* Tests for multiple methods which all end up calling the same final overload. This just adds noise and extra duplicate data to sift through. -* Having too many test cases which only differ by "input data". For example, testing the same operation on a collection with size 1, 10, 100, 1000, 10000, etc. This is a common pitfall when using `[Theory]` and `[InlineData]`. Instead, focus on the key scenarios and minimize the numbers of test cases. This results in less noise, less data to sift through, and less test maintenance cost. -* Performing more than a single operation in the "core test loop". There are times when this is necessary, but they are few and far between. Take extra care if you notice that your test case is doing too many things, and try to focus on creating a small, isolated microbenchmark. +Please read the [Benchmarking workflow for CoreFX](https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-corefx.md) document to find out how to build and run the Performance Tests. \ No newline at end of file