From 2ad9a6ffa7f6bcd31382372609849af5caa6a1bd Mon Sep 17 00:00:00 2001 From: Ian Hays Date: Tue, 13 Oct 2015 14:28:01 -0700 Subject: [PATCH] Update and addition to Performance tests - Made the existing perf tests for Linq follow the new syntax and use the new runner - Removed all references to v5.0 libraries being required as they no longer are - Added new tests using usage data from aspnet/benchmarks - Modified some existing tests to be more easily comparable using analysis tools that look at inlinedata/memberdata (e.g. System.IO.Compression) - Updated the lock files to use the latest xunit-performance package - Modified test structure and innerIteration loops to produce more consistently repeatable results - Updated docs with change to csproj requirements --- .../project-docs/performance-tests.md | 8 +- .../tests/Performance/Perf.HashTable.cs | 48 ++- ...System.Collections.NonGeneric.Tests.csproj | 6 +- .../tests/project.lock.json | 40 ++- .../tests/Performance/Perf.List.cs | 16 + .../tests/System.Collections.Tests.csproj | 5 - .../tests/project.lock.json | 40 ++- .../tests/Performance/Perf.Console.cs | 64 +++- .../tests/System.Console.Tests.csproj | 5 - .../tests/Performance/Perf.Process.cs | 104 ++++-- .../System.Diagnostics.Process.Tests.csproj | 5 - .../tests/project.lock.json | 170 ++++++---- .../Performance/Perf.DateTimeCultureInfo.cs | 60 ++++ .../Performance/Perf.NumberCultureInfo.cs | 37 +++ .../tests/System.Globalization.Tests.csproj | 7 +- .../tests/project.lock.json | 40 ++- .../tests/Performance/Perf.DeflateStream.cs | 149 +++++---- .../tests/System.IO.Compression.Tests.csproj | 5 - .../tests/project.lock.json | 124 ++++--- .../tests/Performance/Perf.FileStream.cs | 141 ++++++++ .../tests/System.IO.FileSystem.Tests.csproj | 10 +- .../tests/project.lock.json | 90 +++-- .../Performance/Perf.MemoryMappedFile.cs | 69 ++++ .../System.IO.MemoryMappedFiles.Tests.csproj | 11 +- .../tests/project.json | 1 + .../tests/project.lock.json | 116 ++++++- .../Performance/Perf.AnonymousPipeStream.cs | 30 ++ .../tests/Performance/Perf.NamedPipeStream.cs | 66 ++++ .../tests/Performance/Perf.PipeTest.cs | 32 ++ .../tests/System.IO.Pipes.Tests.csproj | 13 +- src/System.IO.Pipes/tests/project.json | 1 + src/System.IO.Pipes/tests/project.lock.json | 136 +++++++- src/System.Linq/tests/Performance/CastPerf.cs | 58 ---- .../tests/Performance/OrderByThenByPerf.cs | 52 --- .../tests/Performance/Perf.Linq.cs | 199 +++++++++++ ...erformanceCore.cs => Perf.LinqTestBase.cs} | 171 +++------- .../tests/Performance/RangeRepeatPerf.cs | 34 -- .../tests/Performance/ReversePerf.cs | 40 --- .../tests/Performance/SkipTakePerf.cs | 52 --- .../ToArrayToListToDictionaryPerf.cs | 82 ----- .../tests/Performance/WhereSelectPerf.cs | 64 ---- .../tests/System.Linq.Tests.csproj | 20 +- src/System.Linq/tests/project.json | 1 + src/System.Linq/tests/project.lock.json | 311 +++++++++++++++++- .../tests/Performance/Perf.Vector2.cs | 98 ++++++ .../tests/Performance/Perf.Vector3.cs | 103 ++++++ .../tests/Performance/Perf.Vector4.cs | 98 ++++++ .../System.Numerics.Vectors.Tests.csproj | 13 +- .../tests/project.json | 1 + .../tests/project.lock.json | 291 +++++++++++++++- .../System.Runtime.Extensions.Tests.csproj | 5 - .../tests/project.lock.json | 50 +-- .../tests/Performance/Perf.DateTime.cs | 16 +- .../tests/Performance/Perf.String.cs | 6 +- .../tests/Performance/Perf.StringBuilder.cs | 18 + .../tests/Performance/Perf.Type.cs | 4 +- .../tests/System.Runtime.Tests.csproj | 5 - src/System.Runtime/tests/project.lock.json | 50 +-- .../tests/Performance/Perf.Encoding.cs | 94 +++++- .../tests/System.Text.Encoding.Tests.csproj | 5 - .../tests/project.lock.json | 20 +- .../tests/System.Threading.Tests.csproj | 5 - src/System.Threading/tests/project.lock.json | 40 ++- .../tests/Performance/Perf.XmlDocument.cs | 38 ++- .../tests/Performance/Perf.XmlNode.cs | 42 ++- .../tests/Performance/Perf.XmlNodeList.cs | 38 ++- .../tests/System.Xml.XmlDocument.Tests.csproj | 5 - .../tests/project.lock.json | 20 +- 68 files changed, 2741 insertions(+), 1057 deletions(-) create mode 100644 src/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs create mode 100644 src/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs create mode 100644 src/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs create mode 100644 src/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs create mode 100644 src/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs create mode 100644 src/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs create mode 100644 src/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs delete mode 100644 src/System.Linq/tests/Performance/CastPerf.cs delete mode 100644 src/System.Linq/tests/Performance/OrderByThenByPerf.cs create mode 100644 src/System.Linq/tests/Performance/Perf.Linq.cs rename src/System.Linq/tests/Performance/{LinqPerformanceCore.cs => Perf.LinqTestBase.cs} (62%) delete mode 100644 src/System.Linq/tests/Performance/RangeRepeatPerf.cs delete mode 100644 src/System.Linq/tests/Performance/ReversePerf.cs delete mode 100644 src/System.Linq/tests/Performance/SkipTakePerf.cs delete mode 100644 src/System.Linq/tests/Performance/ToArrayToListToDictionaryPerf.cs delete mode 100644 src/System.Linq/tests/Performance/WhereSelectPerf.cs create mode 100644 src/System.Numerics.Vectors/tests/Performance/Perf.Vector2.cs create mode 100644 src/System.Numerics.Vectors/tests/Performance/Perf.Vector3.cs create mode 100644 src/System.Numerics.Vectors/tests/Performance/Perf.Vector4.cs diff --git a/Documentation/project-docs/performance-tests.md b/Documentation/project-docs/performance-tests.md index d1fcde5fbf8e..89a12579641c 100644 --- a/Documentation/project-docs/performance-tests.md +++ b/Documentation/project-docs/performance-tests.md @@ -43,12 +43,6 @@ For the time being, perf tests should reside within their own "Performance" fold Start by adding the following lines to the tests csproj: ``` - - - v5.0 - - - @@ -63,7 +57,7 @@ Start by adding the following lines to the tests csproj: Next, the project.json for the tests directory also needs to import the perf stuff: ``` - "Microsoft.DotNet.xunit.performance": "1.0.0-alpha-build0022", + "Microsoft.DotNet.xunit.performance": "1.0.0-*", "xunit": "2.1.0", "xunit.netcore.extensions": "1.0.0-prerelease-*" ``` diff --git a/src/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs b/src/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs index 28a7bc355d21..7342e2d9bfda 100644 --- a/src/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs +++ b/src/System.Collections.NonGeneric/tests/Performance/Perf.HashTable.cs @@ -12,9 +12,13 @@ public class Perf_HashTable public static Hashtable CreateHashtable(int size) { Hashtable ht = new Hashtable(); - PerfUtils utils = new PerfUtils(); - for (int i = 0; i < size; i++) - ht.Add(utils.CreateString(50), utils.CreateString(50)); + Random rand = new Random(341553); + while (ht.Count < size) + { + int key = rand.Next(400000, int.MaxValue); + if (!ht.ContainsKey(key)) + ht.Add(key, rand.Next()); + } return ht; } @@ -35,7 +39,9 @@ public void ctor() } [Benchmark] + [InlineData(1000)] [InlineData(10000)] + [InlineData(100000)] [InlineData(1000000)] public void GetItem(int size) { @@ -43,9 +49,11 @@ public void GetItem(int size) // Setup - utils needs a specific seed to prevent key collision with TestData object result; - PerfUtils utils = new PerfUtils(983452); - string key = utils.CreateString(50); - table.Add(key, "value"); + 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()) @@ -62,7 +70,35 @@ public void GetItem(int size) } [Benchmark] + [InlineData(1000)] + [InlineData(10000)] + [InlineData(100000)] + [InlineData(1000000)] + public void SetItem(int size) + { + Hashtable table = CreateHashtable(size); + Random 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 void Add(int size) { diff --git a/src/System.Collections.NonGeneric/tests/System.Collections.NonGeneric.Tests.csproj b/src/System.Collections.NonGeneric/tests/System.Collections.NonGeneric.Tests.csproj index bfee48163e46..82710b92d4e5 100644 --- a/src/System.Collections.NonGeneric/tests/System.Collections.NonGeneric.Tests.csproj +++ b/src/System.Collections.NonGeneric/tests/System.Collections.NonGeneric.Tests.csproj @@ -9,11 +9,7 @@ System.Collections.NonGeneric.Tests {EE95AE39-845A-42D3-86D0-8065DBE56612} - - - v5.0 - - + diff --git a/src/System.Collections.NonGeneric/tests/project.lock.json b/src/System.Collections.NonGeneric/tests/project.lock.json index fd83b8426dd7..6a6f47727bc3 100644 --- a/src/System.Collections.NonGeneric/tests/project.lock.json +++ b/src/System.Collections.NonGeneric/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -469,7 +469,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -497,9 +497,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -511,8 +511,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -550,25 +550,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -1531,14 +1541,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Collections/tests/Performance/Perf.List.cs b/src/System.Collections/tests/Performance/Perf.List.cs index add4cb847b2d..736203696dd5 100644 --- a/src/System.Collections/tests/Performance/Perf.List.cs +++ b/src/System.Collections/tests/Performance/Perf.List.cs @@ -182,6 +182,22 @@ public void Enumerator(int size) 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)] diff --git a/src/System.Collections/tests/System.Collections.Tests.csproj b/src/System.Collections/tests/System.Collections.Tests.csproj index ef2ffd1da6ef..b066fe057638 100644 --- a/src/System.Collections/tests/System.Collections.Tests.csproj +++ b/src/System.Collections/tests/System.Collections.Tests.csproj @@ -9,11 +9,6 @@ System.Collections.Tests System.Collections.Tests - - - v5.0 - - diff --git a/src/System.Collections/tests/project.lock.json b/src/System.Collections/tests/project.lock.json index 39808e102c36..6a7efe8fe8ee 100644 --- a/src/System.Collections/tests/project.lock.json +++ b/src/System.Collections/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -469,7 +469,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -497,9 +497,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -511,8 +511,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -550,25 +550,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -1531,14 +1541,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Console/tests/Performance/Perf.Console.cs b/src/System.Console/tests/Performance/Perf.Console.cs index 8b202337f5c0..46b5447962ae 100644 --- a/src/System.Console/tests/Performance/Perf.Console.cs +++ b/src/System.Console/tests/Performance/Perf.Console.cs @@ -15,7 +15,6 @@ namespace System.ConsoleTests /// Perf tests for Console are chosen based on which functions have PAL code. They are: /// /// - OpenStandardInput, OpenStandardOutput, OpenStandardError - /// - InputEncoding, OutputEncoding /// - ForegroundColor, BackgroundColor, ResetColor /// public class Perf_Console @@ -85,5 +84,68 @@ public void OpenStandardError() 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/System.Console/tests/System.Console.Tests.csproj b/src/System.Console/tests/System.Console.Tests.csproj index 59d079891d88..cbbeed453867 100644 --- a/src/System.Console/tests/System.Console.Tests.csproj +++ b/src/System.Console/tests/System.Console.Tests.csproj @@ -10,11 +10,6 @@ System.Console.Tests true - - - v5.0 - - diff --git a/src/System.Diagnostics.Process/tests/Performance/Perf.Process.cs b/src/System.Diagnostics.Process/tests/Performance/Perf.Process.cs index d84e1c896cff..0f68bf150324 100644 --- a/src/System.Diagnostics.Process/tests/Performance/Perf.Process.cs +++ b/src/System.Diagnostics.Process/tests/Performance/Perf.Process.cs @@ -4,6 +4,7 @@ using Xunit; using Microsoft.Xunit.Performance; using System.IO; +using System.Collections.Generic; namespace System.Diagnostics.Tests { @@ -12,11 +13,12 @@ public class Perf_Process : ProcessTestBase [Benchmark] public void Kill() { + const int inneriterations = 500; foreach (var iteration in Benchmark.Iterations) { // Create several processes to test on - Process[] processes = new Process[500]; - for (int i = 0; i < 500; i++) + Process[] processes = new Process[inneriterations]; + for (int i = 0; i < inneriterations; i++) { processes[i] = CreateProcessInfinite(); processes[i].Start(); @@ -24,31 +26,50 @@ public void Kill() // Begin Testing - Kill all of the processes using (iteration.StartMeasurement()) - for (int i = 0; i < 500; i++) + for (int i = 0; i < inneriterations; i++) processes[i].Kill(); // Cleanup the processes - for (int i = 0; i < 500; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + proc.WaitForExit(); + proc.Dispose(); + } } } [Benchmark] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - public void GetProcessesByName(int innerIterations) + 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()) { - for (int i = 0; i < innerIterations; i++) - { - 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"); - } + 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] @@ -70,9 +91,13 @@ public void GetId() for (int i = 0; i < 500; i++) id = processes[i].Id; - // Cleanup the processes - for (int i = 0; i < 500; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + if (!proc.HasExited) + proc.Kill(); + proc.WaitForExit(); + proc.Dispose(); + } } } @@ -94,8 +119,13 @@ public void Start() processes[i].Start(); // Cleanup the processes - for (int i = 0; i < 500; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + if (!proc.HasExited) + proc.Kill(); + proc.WaitForExit(); + proc.Dispose(); + } } } @@ -119,8 +149,13 @@ public void GetHasExited() result = processes[i].HasExited; // Cleanup the processes - for (int i = 0; i < 500; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + if (!proc.HasExited) + proc.Kill(); + proc.WaitForExit(); + proc.Dispose(); + } } } @@ -145,8 +180,10 @@ public void GetExitCode() result = processes[i].ExitCode; // Cleanup the processes - for (int i = 0; i < 500; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + proc.Dispose(); + } } } @@ -161,6 +198,7 @@ public void GetStartInfo() for (int i = 0; i < 500; i++) { processes[i] = CreateProcess(); + processes[i].Start(); } // Begin Testing @@ -169,8 +207,13 @@ public void GetStartInfo() result = processes[i].StartInfo; // Cleanup the processes - for (int i = 0; i < 500; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + if (!proc.HasExited) + proc.Kill(); + proc.WaitForExit(); + proc.Dispose(); + } } } @@ -203,8 +246,13 @@ public void GetStandardOutput() processes[i].StandardOutput.ReadToEnd(); // Cleanup the processes - for (int i = 0; i < innerIterations; i++) - processes[i].Dispose(); + foreach (Process proc in processes) + { + if (!proc.HasExited) + proc.Kill(); + proc.WaitForExit(); + proc.Dispose(); + } } } } diff --git a/src/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj b/src/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj index dfc2dea215df..01ab12c7dd42 100644 --- a/src/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj +++ b/src/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj @@ -11,11 +11,6 @@ b62eec4b true - - - v5.0 - - diff --git a/src/System.Diagnostics.Process/tests/project.lock.json b/src/System.Diagnostics.Process/tests/project.lock.json index d41e080a5e3a..5bfc9416836e 100644 --- a/src/System.Diagnostics.Process/tests/project.lock.json +++ b/src/System.Diagnostics.Process/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -46,7 +46,7 @@ "lib/dotnet/Microsoft.Win32.Primitives.dll": {} } }, - "Microsoft.Win32.Registry/4.0.0-beta-23401": { + "Microsoft.Win32.Registry/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -76,7 +76,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -172,7 +172,7 @@ "lib/dotnet/System.IO.FileSystem.Primitives.dll": {} } }, - "System.IO.Pipes/4.0.0-beta-23401": { + "System.IO.Pipes/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -333,7 +333,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -373,7 +373,7 @@ "lib/dotnet/System.Security.Principal.dll": {} } }, - "System.Security.Principal.Windows/4.0.0-beta-23401": { + "System.Security.Principal.Windows/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Collections": "4.0.0", @@ -490,7 +490,7 @@ "lib/DNXCore50/System.Threading.Tasks.dll": {} } }, - "System.Threading.Thread/4.0.0-beta-23401": { + "System.Threading.Thread/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -502,7 +502,7 @@ "lib/DNXCore50/System.Threading.Thread.dll": {} } }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0", @@ -610,7 +610,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -638,9 +638,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -652,8 +652,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -689,27 +689,27 @@ "ref/xamarinmac20/_._" ] }, - "Microsoft.Win32.Registry/4.0.0-beta-23401": { + "Microsoft.Win32.Registry/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "Zjow/Nf5YdeHOs/NmFNb8Gc3EpomccuoVkRH1zGCOGDzome2KhmlGdFeQcRrj5SPOC/JFGZAdPX4VO9gVYlmcw==", + "sha512": "ec40UVuBPG4ZhPz52DtURzOZB4RqFDinns7v6nXe4kRZuL1cjESWMNtTR9/ZzPad8hcFr12Ny5jFfdHqOHPMNg==", "files": [ - "lib/DNXCore50/de/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/es/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/fr/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/it/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/ja/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/ko/Microsoft.Win32.Registry.xml", "lib/DNXCore50/Microsoft.Win32.Registry.dll", - "lib/DNXCore50/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/ru/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/zh-hans/Microsoft.Win32.Registry.xml", - "lib/DNXCore50/zh-hant/Microsoft.Win32.Registry.xml", "lib/net46/Microsoft.Win32.Registry.dll", - "Microsoft.Win32.Registry.4.0.0-beta-23401.nupkg", - "Microsoft.Win32.Registry.4.0.0-beta-23401.nupkg.sha512", + "Microsoft.Win32.Registry.4.0.0-beta-23409.nupkg", + "Microsoft.Win32.Registry.4.0.0-beta-23409.nupkg.sha512", "Microsoft.Win32.Registry.nuspec", + "ref/dotnet/de/Microsoft.Win32.Registry.xml", + "ref/dotnet/es/Microsoft.Win32.Registry.xml", + "ref/dotnet/fr/Microsoft.Win32.Registry.xml", + "ref/dotnet/it/Microsoft.Win32.Registry.xml", + "ref/dotnet/ja/Microsoft.Win32.Registry.xml", + "ref/dotnet/ko/Microsoft.Win32.Registry.xml", "ref/dotnet/Microsoft.Win32.Registry.dll", + "ref/dotnet/Microsoft.Win32.Registry.xml", + "ref/dotnet/ru/Microsoft.Win32.Registry.xml", + "ref/dotnet/zh-hans/Microsoft.Win32.Registry.xml", + "ref/dotnet/zh-hant/Microsoft.Win32.Registry.xml", "ref/net46/Microsoft.Win32.Registry.dll" ] }, @@ -747,25 +747,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -969,17 +979,27 @@ "System.IO.FileSystem.Primitives.nuspec" ] }, - "System.IO.Pipes/4.0.0-beta-23401": { + "System.IO.Pipes/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "y7dWdln6qDt9iNfqJY/vo0X+WBJvMiW23jQQEE7dI/4dKsj7zMx5dhPAKhs4dSBA1fwiPNc3q2TTtUCcevJAMg==", + "sha512": "xpeTa4vA19OQYFNBS6kXjrlYUm1OzLUGZaxhe4sPd04LngRBh8X4zaXZ/25YXUGvqTkavHddxa8tEDGTumF/aw==", "files": [ "lib/net46/System.IO.Pipes.dll", + "ref/dotnet/de/System.IO.Pipes.xml", + "ref/dotnet/es/System.IO.Pipes.xml", + "ref/dotnet/fr/System.IO.Pipes.xml", + "ref/dotnet/it/System.IO.Pipes.xml", + "ref/dotnet/ja/System.IO.Pipes.xml", + "ref/dotnet/ko/System.IO.Pipes.xml", + "ref/dotnet/ru/System.IO.Pipes.xml", "ref/dotnet/System.IO.Pipes.dll", + "ref/dotnet/System.IO.Pipes.xml", + "ref/dotnet/zh-hans/System.IO.Pipes.xml", + "ref/dotnet/zh-hant/System.IO.Pipes.xml", "ref/net46/System.IO.Pipes.dll", "runtime.json", - "System.IO.Pipes.4.0.0-beta-23401.nupkg", - "System.IO.Pipes.4.0.0-beta-23401.nupkg.sha512", + "System.IO.Pipes.4.0.0-beta-23409.nupkg", + "System.IO.Pipes.4.0.0-beta-23409.nupkg.sha512", "System.IO.Pipes.nuspec" ] }, @@ -1398,10 +1418,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -1413,8 +1433,8 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, @@ -1483,27 +1503,27 @@ "System.Security.Principal.nuspec" ] }, - "System.Security.Principal.Windows/4.0.0-beta-23401": { + "System.Security.Principal.Windows/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "KI1teeWjqOT+Nen1ShiGjwTQ09/a6OxJw/Fn/Xx1BQ557COzVD//MpdzlCrcBE1gepBuPwHlkjtT4VY2Yb9vWA==", + "sha512": "l24CzvkR0FUSmojdk/cXkvPKRqZ2jIJ8h2d440kFwG6yyyJwvOcZkzYDR/XV2npEmls13HcA+KvMsXxmprLn6A==", "files": [ - "lib/DNXCore50/de/System.Security.Principal.Windows.xml", - "lib/DNXCore50/es/System.Security.Principal.Windows.xml", - "lib/DNXCore50/fr/System.Security.Principal.Windows.xml", - "lib/DNXCore50/it/System.Security.Principal.Windows.xml", - "lib/DNXCore50/ja/System.Security.Principal.Windows.xml", - "lib/DNXCore50/ko/System.Security.Principal.Windows.xml", - "lib/DNXCore50/ru/System.Security.Principal.Windows.xml", "lib/DNXCore50/System.Security.Principal.Windows.dll", - "lib/DNXCore50/System.Security.Principal.Windows.xml", - "lib/DNXCore50/zh-hans/System.Security.Principal.Windows.xml", - "lib/DNXCore50/zh-hant/System.Security.Principal.Windows.xml", "lib/net46/System.Security.Principal.Windows.dll", + "ref/dotnet/de/System.Security.Principal.Windows.xml", + "ref/dotnet/es/System.Security.Principal.Windows.xml", + "ref/dotnet/fr/System.Security.Principal.Windows.xml", + "ref/dotnet/it/System.Security.Principal.Windows.xml", + "ref/dotnet/ja/System.Security.Principal.Windows.xml", + "ref/dotnet/ko/System.Security.Principal.Windows.xml", + "ref/dotnet/ru/System.Security.Principal.Windows.xml", "ref/dotnet/System.Security.Principal.Windows.dll", + "ref/dotnet/System.Security.Principal.Windows.xml", + "ref/dotnet/zh-hans/System.Security.Principal.Windows.xml", + "ref/dotnet/zh-hant/System.Security.Principal.Windows.xml", "ref/net46/System.Security.Principal.Windows.dll", - "System.Security.Principal.Windows.4.0.0-beta-23401.nupkg", - "System.Security.Principal.Windows.4.0.0-beta-23401.nupkg.sha512", + "System.Security.Principal.Windows.4.0.0-beta-23409.nupkg", + "System.Security.Principal.Windows.4.0.0-beta-23409.nupkg.sha512", "System.Security.Principal.Windows.nuspec" ] }, @@ -1744,10 +1764,10 @@ "System.Threading.Tasks.nuspec" ] }, - "System.Threading.Thread/4.0.0-beta-23401": { + "System.Threading.Thread/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "rkyJcFW7yT5BqvyNBbJRPeG9L4T0MBWeG+xfNjI/eJHf5Go217I+09GRK8GAkAmgYwVScVUmVtuLdD4pAUnFMA==", + "sha512": "gtquHsK+pROh1WC8XyxVTypw/b6ukjOUndSyd1+snVER/92IkuklTW9xN6qUE8c+nBNuZO/lNaag0yy7TxnpAQ==", "files": [ "lib/DNXCore50/System.Threading.Thread.dll", "lib/MonoAndroid10/_._", @@ -1755,21 +1775,31 @@ "lib/net46/System.Threading.Thread.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Threading.Thread.xml", + "ref/dotnet/es/System.Threading.Thread.xml", + "ref/dotnet/fr/System.Threading.Thread.xml", + "ref/dotnet/it/System.Threading.Thread.xml", + "ref/dotnet/ja/System.Threading.Thread.xml", + "ref/dotnet/ko/System.Threading.Thread.xml", + "ref/dotnet/ru/System.Threading.Thread.xml", "ref/dotnet/System.Threading.Thread.dll", + "ref/dotnet/System.Threading.Thread.xml", + "ref/dotnet/zh-hans/System.Threading.Thread.xml", + "ref/dotnet/zh-hant/System.Threading.Thread.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Threading.Thread.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", - "System.Threading.Thread.4.0.0-beta-23401.nupkg", - "System.Threading.Thread.4.0.0-beta-23401.nupkg.sha512", + "System.Threading.Thread.4.0.0-beta-23409.nupkg", + "System.Threading.Thread.4.0.0-beta-23409.nupkg.sha512", "System.Threading.Thread.nuspec" ] }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "serviceable": true, - "sha512": "uYRRB5hlSzSN2tQtqwTA+mkLBow0pQwxA7xvKQhB4FY+ooK3xYnwVRzXnKxf1D5o/uHKHz4HeMuBlvTv5JG4zg==", + "sha512": "GHQA83v+KePBnQvbHZIHx+AEP1Yi8D9DI3yXMM8PN89sUn+gVi9SuAachqgJ1syJ5b5x9a2wZnF/2z3PXlFsSQ==", "files": [ "lib/DNXCore50/System.Threading.ThreadPool.dll", "lib/MonoAndroid10/_._", @@ -1777,14 +1807,24 @@ "lib/net46/System.Threading.ThreadPool.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Threading.ThreadPool.xml", + "ref/dotnet/es/System.Threading.ThreadPool.xml", + "ref/dotnet/fr/System.Threading.ThreadPool.xml", + "ref/dotnet/it/System.Threading.ThreadPool.xml", + "ref/dotnet/ja/System.Threading.ThreadPool.xml", + "ref/dotnet/ko/System.Threading.ThreadPool.xml", + "ref/dotnet/ru/System.Threading.ThreadPool.xml", "ref/dotnet/System.Threading.ThreadPool.dll", + "ref/dotnet/System.Threading.ThreadPool.xml", + "ref/dotnet/zh-hans/System.Threading.ThreadPool.xml", + "ref/dotnet/zh-hant/System.Threading.ThreadPool.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Threading.ThreadPool.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", - "System.Threading.ThreadPool.4.0.10-beta-23401.nupkg", - "System.Threading.ThreadPool.4.0.10-beta-23401.nupkg.sha512", + "System.Threading.ThreadPool.4.0.10-beta-23409.nupkg", + "System.Threading.ThreadPool.4.0.10-beta-23409.nupkg.sha512", "System.Threading.ThreadPool.nuspec" ] }, @@ -1905,14 +1945,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs b/src/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs new file mode 100644 index 000000000000..2c9ec4cf37ba --- /dev/null +++ b/src/System.Globalization/tests/Performance/Perf.DateTimeCultureInfo.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license 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/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs b/src/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs new file mode 100644 index 000000000000..c3a6e4ff4faa --- /dev/null +++ b/src/System.Globalization/tests/Performance/Perf.NumberCultureInfo.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license 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/System.Globalization/tests/System.Globalization.Tests.csproj b/src/System.Globalization/tests/System.Globalization.Tests.csproj index 2927beda5ba3..371819745fc4 100644 --- a/src/System.Globalization/tests/System.Globalization.Tests.csproj +++ b/src/System.Globalization/tests/System.Globalization.Tests.csproj @@ -10,11 +10,6 @@ System.Globalization.Tests true - - - v5.0 - - @@ -178,6 +173,8 @@ + + Common\System\PerfUtils.cs diff --git a/src/System.Globalization/tests/project.lock.json b/src/System.Globalization/tests/project.lock.json index fb77bdf769ce..0bfbaee3a766 100644 --- a/src/System.Globalization/tests/project.lock.json +++ b/src/System.Globalization/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -57,7 +57,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -494,7 +494,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -522,9 +522,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -536,8 +536,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -608,25 +608,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -1622,14 +1632,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.IO.Compression/tests/Performance/Perf.DeflateStream.cs b/src/System.IO.Compression/tests/Performance/Perf.DeflateStream.cs index 169c371ef1e0..28ef9cebfbe6 100644 --- a/src/System.IO.Compression/tests/Performance/Perf.DeflateStream.cs +++ b/src/System.IO.Compression/tests/Performance/Perf.DeflateStream.cs @@ -10,75 +10,91 @@ namespace System.IO.Compression.Tests { public class Perf_DeflateStream { - private static List _compressedFiles; - private static List _byteArraysToCompress; - - /// - /// Yields an Enumerable list of paths to GZTestData files - /// - public static IEnumerable CompressedFiles() + /// + private static string CreateCompressedFile(CompressionType type) { - if (_compressedFiles == null) - { - PerfUtils utils = new PerfUtils(); - _compressedFiles = new List(); - // Crypto random data - byte[] bytes = new byte[100000000]; - var rand = RandomNumberGenerator.Create(); - rand.GetBytes(bytes); - string filePath = utils.GetTestFilePath() + ".gz"; - using (FileStream output = File.Create(filePath)) - using (GZipStream zip = new GZipStream(output, CompressionMode.Compress)) - zip.Write(bytes, 0, bytes.Length); - _compressedFiles.Add(new object[] { filePath }); - - // Create a compressed file with repeated segments - bytes = Text.Encoding.UTF8.GetBytes(utils.CreateString(100000)); - filePath = utils.GetTestFilePath() + ".gz"; - using (FileStream output = File.Create(filePath)) - using (GZipStream zip = new GZipStream(output, CompressionMode.Compress)) - for (int i = 0; i < 1000; i++) - zip.Write(bytes, 0, bytes.Length); - _compressedFiles.Add(new object[] { filePath }); + const int fileSize = 100000000; + PerfUtils utils = new PerfUtils(); + string filePath = utils.GetTestFilePath() + ".gz"; + switch (type) + { + case CompressionType.CryptoRandom: + using (RandomNumberGenerator rand = RandomNumberGenerator.Create()) + { + byte[] bytes = new byte[fileSize]; + rand.GetBytes(bytes); + using (FileStream output = File.Create(filePath)) + using (GZipStream zip = new GZipStream(output, CompressionMode.Compress)) + zip.Write(bytes, 0, bytes.Length); + } + break; + case CompressionType.RepeatedSegments: + { + byte[] bytes = new byte[fileSize / 1000]; + new Random(128453).NextBytes(bytes); + using (FileStream output = File.Create(filePath)) + using (GZipStream zip = new GZipStream(output, CompressionMode.Compress)) + for (int i = 0; i < 1000; i++) + zip.Write(bytes, 0, bytes.Length); + } + break; + case CompressionType.NormalData: + { + byte[] bytes = new byte[fileSize]; + new Random(128453).NextBytes(bytes); + using (FileStream output = File.Create(filePath)) + using (GZipStream zip = new GZipStream(output, CompressionMode.Compress)) + zip.Write(bytes, 0, bytes.Length); + } + break; } - return _compressedFiles; + return filePath; } - // Creates byte arrays that contain random data to be compressed - public static IEnumerable ByteArraysToCompress() + private static byte[] CreateBytesToCompress(CompressionType type) { - if (_byteArraysToCompress == null) + const int fileSize = 100000000; + byte[] bytes = new byte[fileSize]; + switch (type) { - PerfUtils utils = new PerfUtils(); - _byteArraysToCompress = new List(); - - // Regular, semi well formed data - _byteArraysToCompress.Add(new object[] { Text.Encoding.UTF8.GetBytes(utils.CreateString(100000000)) }); - - // Crypto random data - { - byte[] bytes = new byte[100000000]; - var rand = RandomNumberGenerator.Create(); - rand.GetBytes(bytes); - _byteArraysToCompress.Add(new object[] { bytes }); - } - - // Highly repeated data - { - byte[] bytes = new byte[101000000]; - byte[] small = Text.Encoding.UTF8.GetBytes(utils.CreateString(100000)); - for (int i = 0; i < 1000; i++) - small.CopyTo(bytes, 100000 * i); - _byteArraysToCompress.Add(new object[] { bytes }); - } + case CompressionType.CryptoRandom: + using (RandomNumberGenerator rand = RandomNumberGenerator.Create()) + rand.GetBytes(bytes); + break; + case CompressionType.RepeatedSegments: + { + byte[] small = new byte[1000]; + new Random(123453).NextBytes(small); + for (int i = 0; i < fileSize / 1000; i++) + { + small.CopyTo(bytes, 1000 * i); + } + } + break; + case CompressionType.VeryRepetitive: + { + byte[] small = new byte[100]; + new Random(123453).NextBytes(small); + for (int i = 0; i < fileSize / 100; i++) + { + small.CopyTo(bytes, 100 * i); + } + break; + } + case CompressionType.NormalData: + new Random(123453).NextBytes(bytes); + break; } - return _byteArraysToCompress; + return bytes; } [Benchmark] - [MemberData("CompressedFiles")] - public async void Decompress(string testFilePath) + [InlineData(CompressionType.CryptoRandom)] + [InlineData(CompressionType.RepeatedSegments)] + [InlineData(CompressionType.NormalData)] + public async void Decompress(CompressionType type) { + string testFilePath = CreateCompressedFile(type); int _bufferSize = 1024; int retCount = -1; var bytes = new byte[_bufferSize]; @@ -97,12 +113,17 @@ public async void Decompress(string testFilePath) } strippedMs.Seek(0, SeekOrigin.Begin); } + File.Delete(testFilePath); } [Benchmark] - [MemberData("ByteArraysToCompress")] - public void Compress(byte[] bytes) + [InlineData(CompressionType.CryptoRandom)] + [InlineData(CompressionType.RepeatedSegments)] + [InlineData(CompressionType.VeryRepetitive)] + [InlineData(CompressionType.NormalData)] + public void Compress(CompressionType type) { + byte[] bytes = CreateBytesToCompress(type); PerfUtils utils = new PerfUtils(); foreach (var iteration in Benchmark.Iterations) { @@ -117,4 +138,12 @@ public void Compress(byte[] bytes) } } } + + public enum CompressionType + { + CryptoRandom = 1, + RepeatedSegments = 2, + VeryRepetitive = 3, + NormalData = 4 + } } diff --git a/src/System.IO.Compression/tests/System.IO.Compression.Tests.csproj b/src/System.IO.Compression/tests/System.IO.Compression.Tests.csproj index a182cdadc2d5..918db53a5703 100644 --- a/src/System.IO.Compression/tests/System.IO.Compression.Tests.csproj +++ b/src/System.IO.Compression/tests/System.IO.Compression.Tests.csproj @@ -8,11 +8,6 @@ Library System.IO.Compression.Tests - - - v5.0 - - diff --git a/src/System.IO.Compression/tests/project.lock.json b/src/System.IO.Compression/tests/project.lock.json index 403e1f023f57..000217289313 100644 --- a/src/System.IO.Compression/tests/project.lock.json +++ b/src/System.IO.Compression/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -312,7 +312,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -321,18 +321,18 @@ "ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {} } }, - "System.Security.Cryptography.Algorithms/4.0.0-beta-23401": { + "System.Security.Cryptography.Algorithms/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", "System.Runtime": "4.0.0", - "System.Security.Cryptography.Primitives": "4.0.0-beta-23401" + "System.Security.Cryptography.Primitives": "4.0.0-beta-23409" }, "compile": { "ref/dotnet/System.Security.Cryptography.Algorithms.dll": {} } }, - "System.Security.Cryptography.Primitives/4.0.0-beta-23401": { + "System.Security.Cryptography.Primitives/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.0", @@ -422,7 +422,7 @@ "lib/DNXCore50/System.Threading.Tasks.dll": {} } }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0", @@ -530,7 +530,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -557,7 +557,7 @@ } }, "DNXCore,Version=v5.0/win7-x86": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -599,7 +599,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -872,7 +872,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -881,18 +881,18 @@ "ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {} } }, - "System.Security.Cryptography.Algorithms/4.0.0-beta-23401": { + "System.Security.Cryptography.Algorithms/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", "System.Runtime": "4.0.0", - "System.Security.Cryptography.Primitives": "4.0.0-beta-23401" + "System.Security.Cryptography.Primitives": "4.0.0-beta-23409" }, "compile": { "ref/dotnet/System.Security.Cryptography.Algorithms.dll": {} } }, - "System.Security.Cryptography.Primitives/4.0.0-beta-23401": { + "System.Security.Cryptography.Primitives/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.0", @@ -982,7 +982,7 @@ "lib/DNXCore50/System.Threading.Tasks.dll": {} } }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0", @@ -1090,7 +1090,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -1117,7 +1117,7 @@ } }, "DNXCore,Version=v5.0/win7-x64": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -1159,7 +1159,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -1432,7 +1432,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -1441,18 +1441,18 @@ "ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {} } }, - "System.Security.Cryptography.Algorithms/4.0.0-beta-23401": { + "System.Security.Cryptography.Algorithms/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", "System.Runtime": "4.0.0", - "System.Security.Cryptography.Primitives": "4.0.0-beta-23401" + "System.Security.Cryptography.Primitives": "4.0.0-beta-23409" }, "compile": { "ref/dotnet/System.Security.Cryptography.Algorithms.dll": {} } }, - "System.Security.Cryptography.Primitives/4.0.0-beta-23401": { + "System.Security.Cryptography.Primitives/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.0", @@ -1542,7 +1542,7 @@ "lib/DNXCore50/System.Threading.Tasks.dll": {} } }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0", @@ -1650,7 +1650,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -1678,9 +1678,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -1692,8 +1692,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -1731,25 +1731,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -2522,10 +2532,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -2537,15 +2547,15 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, - "System.Security.Cryptography.Algorithms/4.0.0-beta-23401": { + "System.Security.Cryptography.Algorithms/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "unUfGNfc/kIWzbGZw+m0WkAlVzc1VhW3ayYhaUJla1B5XVokc0iMMFV9vCOQE54gNOA41E0xEY+EUo+DS9MWfQ==", + "sha512": "+fTP36jzRYPFFG6j3iLDhCp1t7uOg6q7urwe1XAh1JNhqoRPKassTV2FABKzwx1L8LIQXEYIlbK2tb/SOeLcug==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -2559,15 +2569,15 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Security.Cryptography.Algorithms.4.0.0-beta-23401.nupkg", - "System.Security.Cryptography.Algorithms.4.0.0-beta-23401.nupkg.sha512", + "System.Security.Cryptography.Algorithms.4.0.0-beta-23409.nupkg", + "System.Security.Cryptography.Algorithms.4.0.0-beta-23409.nupkg.sha512", "System.Security.Cryptography.Algorithms.nuspec" ] }, - "System.Security.Cryptography.Primitives/4.0.0-beta-23401": { + "System.Security.Cryptography.Primitives/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "RMF1swkhksZRBwFqzeI3axkOFHVILVxtaFuE61hqpuDa0l8y1C//S3QeTaUH6FSpWnhR6U8KCzj9z+tUsvKshg==", + "sha512": "A9uRLcec2cnppupdLyiU3AJCCphk2MQe37Kfm3rA6Oi00mFTfy/fD6SsBjKzJsE6rtx1IjpJUqrNe0dp+r32cg==", "files": [ "lib/dotnet/System.Security.Cryptography.Primitives.dll", "lib/MonoAndroid10/_._", @@ -2581,8 +2591,8 @@ "ref/net46/System.Security.Cryptography.Primitives.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", - "System.Security.Cryptography.Primitives.4.0.0-beta-23401.nupkg", - "System.Security.Cryptography.Primitives.4.0.0-beta-23401.nupkg.sha512", + "System.Security.Cryptography.Primitives.4.0.0-beta-23409.nupkg", + "System.Security.Cryptography.Primitives.4.0.0-beta-23409.nupkg.sha512", "System.Security.Cryptography.Primitives.nuspec" ] }, @@ -2793,10 +2803,10 @@ "System.Threading.Tasks.nuspec" ] }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "serviceable": true, - "sha512": "uYRRB5hlSzSN2tQtqwTA+mkLBow0pQwxA7xvKQhB4FY+ooK3xYnwVRzXnKxf1D5o/uHKHz4HeMuBlvTv5JG4zg==", + "sha512": "GHQA83v+KePBnQvbHZIHx+AEP1Yi8D9DI3yXMM8PN89sUn+gVi9SuAachqgJ1syJ5b5x9a2wZnF/2z3PXlFsSQ==", "files": [ "lib/DNXCore50/System.Threading.ThreadPool.dll", "lib/MonoAndroid10/_._", @@ -2804,14 +2814,24 @@ "lib/net46/System.Threading.ThreadPool.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Threading.ThreadPool.xml", + "ref/dotnet/es/System.Threading.ThreadPool.xml", + "ref/dotnet/fr/System.Threading.ThreadPool.xml", + "ref/dotnet/it/System.Threading.ThreadPool.xml", + "ref/dotnet/ja/System.Threading.ThreadPool.xml", + "ref/dotnet/ko/System.Threading.ThreadPool.xml", + "ref/dotnet/ru/System.Threading.ThreadPool.xml", "ref/dotnet/System.Threading.ThreadPool.dll", + "ref/dotnet/System.Threading.ThreadPool.xml", + "ref/dotnet/zh-hans/System.Threading.ThreadPool.xml", + "ref/dotnet/zh-hant/System.Threading.ThreadPool.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Threading.ThreadPool.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", - "System.Threading.ThreadPool.4.0.10-beta-23401.nupkg", - "System.Threading.ThreadPool.4.0.10-beta-23401.nupkg.sha512", + "System.Threading.ThreadPool.4.0.10-beta-23409.nupkg", + "System.Threading.ThreadPool.4.0.10-beta-23409.nupkg.sha512", "System.Threading.ThreadPool.nuspec" ] }, @@ -2932,14 +2952,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs b/src/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs new file mode 100644 index 000000000000..fff368dd5634 --- /dev/null +++ b/src/System.IO.FileSystem/tests/Performance/Perf.FileStream.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license 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("ReadWriteTestParameters")] + public async void 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("ReadWriteTestParameters")] + public async void 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/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj index e9c3204043d7..ad894ae84600 100644 --- a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj +++ b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -9,11 +9,6 @@ System.IO.FileSystem.Tests InnerLoop;OuterLoop - - - v5.0 - - true AnyCPU @@ -174,9 +169,10 @@ + Common\System\PerfUtils.cs - \ No newline at end of file + diff --git a/src/System.IO.FileSystem/tests/project.lock.json b/src/System.IO.FileSystem/tests/project.lock.json index b8fae35ee27b..55ae38d4b3db 100644 --- a/src/System.IO.FileSystem/tests/project.lock.json +++ b/src/System.IO.FileSystem/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -141,7 +141,7 @@ "lib/dotnet/System.IO.FileSystem.Primitives.dll": {} } }, - "System.IO.Pipes/4.0.0-beta-23401": { + "System.IO.Pipes/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -302,7 +302,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -395,7 +395,7 @@ "lib/DNXCore50/System.Threading.Tasks.dll": {} } }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0", @@ -503,7 +503,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -531,9 +531,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -545,8 +545,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -584,25 +584,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -806,17 +816,27 @@ "System.IO.FileSystem.Primitives.nuspec" ] }, - "System.IO.Pipes/4.0.0-beta-23401": { + "System.IO.Pipes/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "y7dWdln6qDt9iNfqJY/vo0X+WBJvMiW23jQQEE7dI/4dKsj7zMx5dhPAKhs4dSBA1fwiPNc3q2TTtUCcevJAMg==", + "sha512": "xpeTa4vA19OQYFNBS6kXjrlYUm1OzLUGZaxhe4sPd04LngRBh8X4zaXZ/25YXUGvqTkavHddxa8tEDGTumF/aw==", "files": [ "lib/net46/System.IO.Pipes.dll", + "ref/dotnet/de/System.IO.Pipes.xml", + "ref/dotnet/es/System.IO.Pipes.xml", + "ref/dotnet/fr/System.IO.Pipes.xml", + "ref/dotnet/it/System.IO.Pipes.xml", + "ref/dotnet/ja/System.IO.Pipes.xml", + "ref/dotnet/ko/System.IO.Pipes.xml", + "ref/dotnet/ru/System.IO.Pipes.xml", "ref/dotnet/System.IO.Pipes.dll", + "ref/dotnet/System.IO.Pipes.xml", + "ref/dotnet/zh-hans/System.IO.Pipes.xml", + "ref/dotnet/zh-hant/System.IO.Pipes.xml", "ref/net46/System.IO.Pipes.dll", "runtime.json", - "System.IO.Pipes.4.0.0-beta-23401.nupkg", - "System.IO.Pipes.4.0.0-beta-23401.nupkg.sha512", + "System.IO.Pipes.4.0.0-beta-23409.nupkg", + "System.IO.Pipes.4.0.0-beta-23409.nupkg.sha512", "System.IO.Pipes.nuspec" ] }, @@ -1235,10 +1255,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -1250,8 +1270,8 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, @@ -1495,10 +1515,10 @@ "System.Threading.Tasks.nuspec" ] }, - "System.Threading.ThreadPool/4.0.10-beta-23401": { + "System.Threading.ThreadPool/4.0.10-beta-23409": { "type": "package", "serviceable": true, - "sha512": "uYRRB5hlSzSN2tQtqwTA+mkLBow0pQwxA7xvKQhB4FY+ooK3xYnwVRzXnKxf1D5o/uHKHz4HeMuBlvTv5JG4zg==", + "sha512": "GHQA83v+KePBnQvbHZIHx+AEP1Yi8D9DI3yXMM8PN89sUn+gVi9SuAachqgJ1syJ5b5x9a2wZnF/2z3PXlFsSQ==", "files": [ "lib/DNXCore50/System.Threading.ThreadPool.dll", "lib/MonoAndroid10/_._", @@ -1506,14 +1526,24 @@ "lib/net46/System.Threading.ThreadPool.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Threading.ThreadPool.xml", + "ref/dotnet/es/System.Threading.ThreadPool.xml", + "ref/dotnet/fr/System.Threading.ThreadPool.xml", + "ref/dotnet/it/System.Threading.ThreadPool.xml", + "ref/dotnet/ja/System.Threading.ThreadPool.xml", + "ref/dotnet/ko/System.Threading.ThreadPool.xml", + "ref/dotnet/ru/System.Threading.ThreadPool.xml", "ref/dotnet/System.Threading.ThreadPool.dll", + "ref/dotnet/System.Threading.ThreadPool.xml", + "ref/dotnet/zh-hans/System.Threading.ThreadPool.xml", + "ref/dotnet/zh-hant/System.Threading.ThreadPool.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Threading.ThreadPool.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", - "System.Threading.ThreadPool.4.0.10-beta-23401.nupkg", - "System.Threading.ThreadPool.4.0.10-beta-23401.nupkg.sha512", + "System.Threading.ThreadPool.4.0.10-beta-23409.nupkg", + "System.Threading.ThreadPool.4.0.10-beta-23409.nupkg.sha512", "System.Threading.ThreadPool.nuspec" ] }, @@ -1634,14 +1664,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs b/src/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs new file mode 100644 index 000000000000..6de7b58a2d8f --- /dev/null +++ b/src/System.IO.MemoryMappedFiles/tests/Performance/Perf.MemoryMappedFile.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.IO; +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; + MemoryMappedFile[] files = new MemoryMappedFile[innerIterations]; + foreach (var iteration in Benchmark.Iterations) + { + using (iteration.StartMeasurement()) + for (int i = 0; i < innerIterations; i++) + files[i] = MemoryMappedFile.CreateNew(null, capacity); + for (int i = 0; i < innerIterations; i++) + files[i].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)) + { } + } + + [Benchmark] + [InlineData(10000)] + [InlineData(100000)] + [InlineData(1000000)] + public void Dispose(int capacity) + { + const int innerIterations = 1000; + MemoryMappedFile[] files = new MemoryMappedFile[innerIterations]; + foreach (var iteration in Benchmark.Iterations) + { + for (int i = 0; i < innerIterations; i++) + files[i] = MemoryMappedFile.CreateNew(null, capacity); + using (iteration.StartMeasurement()) + for (int i = 0; i < innerIterations; i++) + files[i].Dispose(); + } + } + } +} diff --git a/src/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj b/src/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj index b048a3b85383..845d9bf49cb5 100644 --- a/src/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj +++ b/src/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -31,6 +31,13 @@ Common\System\IO\FileCleanupTestBase.cs + + + + + Common\System\PerfUtils.cs + + @@ -44,4 +51,4 @@ - \ No newline at end of file + diff --git a/src/System.IO.MemoryMappedFiles/tests/project.json b/src/System.IO.MemoryMappedFiles/tests/project.json index ef2892e1d9c6..22681b2e75c2 100644 --- a/src/System.IO.MemoryMappedFiles/tests/project.json +++ b/src/System.IO.MemoryMappedFiles/tests/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.DotNet.xunit.performance": "1.0.0-*", "System.Globalization": "4.0.10", "System.IO": "4.0.10", "System.IO.FileSystem": "4.0.0", diff --git a/src/System.IO.MemoryMappedFiles/tests/project.lock.json b/src/System.IO.MemoryMappedFiles/tests/project.lock.json index 44812bd3095f..d77a7e1e9421 100644 --- a/src/System.IO.MemoryMappedFiles/tests/project.lock.json +++ b/src/System.IO.MemoryMappedFiles/tests/project.lock.json @@ -3,6 +3,36 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.10", + "System.Diagnostics.Debug": "4.0.10", + "System.Diagnostics.Tracing": "4.0.20", + "System.Globalization": "4.0.10", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.0", + "System.Reflection": "4.0.10", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Tasks": "4.0.10", + "xunit.abstractions": "2.0.0", + "xunit.extensibility.core": "2.1.0", + "xunit.extensibility.execution": "2.1.0" + }, + "compile": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + }, + "runtime": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + } + }, "System.Collections/4.0.10": { "type": "package", "dependencies": { @@ -27,6 +57,18 @@ "lib/DNXCore50/System.Diagnostics.Debug.dll": {} } }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0" + }, + "compile": { + "ref/dotnet/System.Diagnostics.Tracing.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Diagnostics.Tracing.dll": {} + } + }, "System.Globalization/4.0.10": { "type": "package", "dependencies": { @@ -255,7 +297,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -431,7 +473,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -459,6 +501,25 @@ } }, "libraries": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", + "files": [ + "lib/dotnet/xunit.performance.core.dll", + "lib/dotnet/xunit.performance.core.pdb", + "lib/dotnet/xunit.performance.core.XML", + "lib/dotnet/xunit.performance.execution.dotnet.dll", + "lib/dotnet/xunit.performance.execution.dotnet.pdb", + "lib/net46/xunit.performance.core.dll", + "lib/net46/xunit.performance.core.pdb", + "lib/net46/xunit.performance.core.XML", + "lib/net46/xunit.performance.execution.desktop.dll", + "lib/net46/xunit.performance.execution.desktop.pdb", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.nuspec" + ] + }, "System.Collections/4.0.10": { "type": "package", "serviceable": true, @@ -527,6 +588,40 @@ "System.Diagnostics.Debug.nuspec" ] }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "serviceable": true, + "sha512": "gn/wexGHc35Fv++5L1gYHMY5g25COfiZ0PGrL+3PfwzoJd4X2LbTAm/U8d385SI6BKQBI/z4dQfvneS9J27+Tw==", + "files": [ + "lib/DNXCore50/System.Diagnostics.Tracing.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netcore50/System.Diagnostics.Tracing.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Diagnostics.Tracing.xml", + "ref/dotnet/es/System.Diagnostics.Tracing.xml", + "ref/dotnet/fr/System.Diagnostics.Tracing.xml", + "ref/dotnet/it/System.Diagnostics.Tracing.xml", + "ref/dotnet/ja/System.Diagnostics.Tracing.xml", + "ref/dotnet/ko/System.Diagnostics.Tracing.xml", + "ref/dotnet/ru/System.Diagnostics.Tracing.xml", + "ref/dotnet/System.Diagnostics.Tracing.dll", + "ref/dotnet/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hans/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hant/System.Diagnostics.Tracing.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "runtimes/win8-aot/lib/netcore50/System.Diagnostics.Tracing.dll", + "System.Diagnostics.Tracing.4.0.20.nupkg", + "System.Diagnostics.Tracing.4.0.20.nupkg.sha512", + "System.Diagnostics.Tracing.nuspec" + ] + }, "System.Globalization/4.0.10": { "type": "package", "sha512": "kzRtbbCNAxdafFBDogcM36ehA3th8c1PGiz8QRkZn8O5yMBorDHSK8/TGJPYOaCS5zdsGk0u9qXHnW91nqy7fw==", @@ -1106,10 +1201,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -1121,8 +1216,8 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, @@ -1450,20 +1545,21 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } }, "projectFileDependencyGroups": { "": [ + "Microsoft.DotNet.xunit.performance >= 1.0.0-*", "System.Globalization >= 4.0.10", "System.IO >= 4.0.10", "System.IO.FileSystem >= 4.0.0", diff --git a/src/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs b/src/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs new file mode 100644 index 000000000000..ebf023db8d27 --- /dev/null +++ b/src/System.IO.Pipes/tests/Performance/Perf.AnonymousPipeStream.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license 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/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs b/src/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs new file mode 100644 index 000000000000..471bde5c28a8 --- /dev/null +++ b/src/System.IO.Pipes/tests/Performance/Perf.NamedPipeStream.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license 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/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs b/src/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs new file mode 100644 index 000000000000..14558c979d19 --- /dev/null +++ b/src/System.IO.Pipes/tests/Performance/Perf.PipeTest.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Xunit.Performance; +using Xunit; +using System.Threading.Tasks; + +namespace System.IO.Pipes.Tests +{ + public abstract class Perf_PipeTest : PipeTestBase + { + [Benchmark] + [InlineData(1000000)] + public async void 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/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj b/src/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj index ef847db2cef1..921d4e33e2dc 100644 --- a/src/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj +++ b/src/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -37,6 +37,15 @@ + + + + + + + Common\System\PerfUtils.cs + + @@ -52,4 +61,4 @@ - \ No newline at end of file + diff --git a/src/System.IO.Pipes/tests/project.json b/src/System.IO.Pipes/tests/project.json index 1d3dfbc38d16..1b51d37a8304 100644 --- a/src/System.IO.Pipes/tests/project.json +++ b/src/System.IO.Pipes/tests/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.DotNet.xunit.performance": "1.0.0-*", "System.Console": "4.0.0-beta-*", "System.Diagnostics.Debug": "4.0.10", "System.Globalization": "4.0.10", diff --git a/src/System.IO.Pipes/tests/project.lock.json b/src/System.IO.Pipes/tests/project.lock.json index 67200b150fd0..9fc2a93d4ebc 100644 --- a/src/System.IO.Pipes/tests/project.lock.json +++ b/src/System.IO.Pipes/tests/project.lock.json @@ -3,6 +3,36 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.10", + "System.Diagnostics.Debug": "4.0.10", + "System.Diagnostics.Tracing": "4.0.20", + "System.Globalization": "4.0.10", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.0", + "System.Reflection": "4.0.10", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Tasks": "4.0.10", + "xunit.abstractions": "2.0.0", + "xunit.extensibility.core": "2.1.0", + "xunit.extensibility.execution": "2.1.0" + }, + "compile": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + }, + "runtime": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + } + }, "System.Collections/4.0.10": { "type": "package", "dependencies": { @@ -15,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -37,6 +67,18 @@ "lib/DNXCore50/System.Diagnostics.Debug.dll": {} } }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0" + }, + "compile": { + "ref/dotnet/System.Diagnostics.Tracing.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Diagnostics.Tracing.dll": {} + } + }, "System.Globalization/4.0.10": { "type": "package", "dependencies": { @@ -247,7 +289,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -435,7 +477,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -463,6 +505,25 @@ } }, "libraries": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", + "files": [ + "lib/dotnet/xunit.performance.core.dll", + "lib/dotnet/xunit.performance.core.pdb", + "lib/dotnet/xunit.performance.core.XML", + "lib/dotnet/xunit.performance.execution.dotnet.dll", + "lib/dotnet/xunit.performance.execution.dotnet.pdb", + "lib/net46/xunit.performance.core.dll", + "lib/net46/xunit.performance.core.pdb", + "lib/net46/xunit.performance.core.XML", + "lib/net46/xunit.performance.execution.desktop.dll", + "lib/net46/xunit.performance.execution.desktop.pdb", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.nuspec" + ] + }, "System.Collections/4.0.10": { "type": "package", "serviceable": true, @@ -497,25 +558,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -553,6 +624,40 @@ "System.Diagnostics.Debug.nuspec" ] }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "serviceable": true, + "sha512": "gn/wexGHc35Fv++5L1gYHMY5g25COfiZ0PGrL+3PfwzoJd4X2LbTAm/U8d385SI6BKQBI/z4dQfvneS9J27+Tw==", + "files": [ + "lib/DNXCore50/System.Diagnostics.Tracing.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netcore50/System.Diagnostics.Tracing.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Diagnostics.Tracing.xml", + "ref/dotnet/es/System.Diagnostics.Tracing.xml", + "ref/dotnet/fr/System.Diagnostics.Tracing.xml", + "ref/dotnet/it/System.Diagnostics.Tracing.xml", + "ref/dotnet/ja/System.Diagnostics.Tracing.xml", + "ref/dotnet/ko/System.Diagnostics.Tracing.xml", + "ref/dotnet/ru/System.Diagnostics.Tracing.xml", + "ref/dotnet/System.Diagnostics.Tracing.dll", + "ref/dotnet/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hans/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hant/System.Diagnostics.Tracing.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "runtimes/win8-aot/lib/netcore50/System.Diagnostics.Tracing.dll", + "System.Diagnostics.Tracing.4.0.20.nupkg", + "System.Diagnostics.Tracing.4.0.20.nupkg.sha512", + "System.Diagnostics.Tracing.nuspec" + ] + }, "System.Globalization/4.0.10": { "type": "package", "sha512": "kzRtbbCNAxdafFBDogcM36ehA3th8c1PGiz8QRkZn8O5yMBorDHSK8/TGJPYOaCS5zdsGk0u9qXHnW91nqy7fw==", @@ -1100,10 +1205,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -1115,8 +1220,8 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, @@ -1477,20 +1582,21 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } }, "projectFileDependencyGroups": { "": [ + "Microsoft.DotNet.xunit.performance >= 1.0.0-*", "System.Console >= 4.0.0-beta-*", "System.Diagnostics.Debug >= 4.0.10", "System.Globalization >= 4.0.10", diff --git a/src/System.Linq/tests/Performance/CastPerf.cs b/src/System.Linq/tests/Performance/CastPerf.cs deleted file mode 100644 index 9619f4fec9a9..000000000000 --- a/src/System.Linq/tests/Performance/CastPerf.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class CastPerf - { - private class BaseClass - { - public int Value; - } - private class ChildClass: BaseClass - { - public int ChildValue; - } - - - private void RunTestGroup(string description, TSource val, Func, IEnumerable> linqApply) - { - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.Measure(1000000, 500, val, LinqPerformanceCore.WrapperType.NoWrap, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 500, val, LinqPerformanceCore.WrapperType.IEnumerable, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 500, val, LinqPerformanceCore.WrapperType.IReadOnlyCollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 500, val, LinqPerformanceCore.WrapperType.ICollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - - //[Fact] - public void Cast_SameType_Performance() - { - RunTestGroup("Cast_SameType", 1, col => col.Cast()); - } - - - //[Fact] - public void Cast_ToBaseClass_Performance() - { - RunTestGroup("Cast_ToBaseClass", new ChildClass() { Value = 1, ChildValue = 2 }, col => col.Cast()); - } - } -} diff --git a/src/System.Linq/tests/Performance/OrderByThenByPerf.cs b/src/System.Linq/tests/Performance/OrderByThenByPerf.cs deleted file mode 100644 index 42f2897b727d..000000000000 --- a/src/System.Linq/tests/Performance/OrderByThenByPerf.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class OrderByThenByPerf - { - private void RunTestGroup(string description, Func, IEnumerable> linqApply) - { - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.Measure(1000000, 100, LinqPerformanceCore.WrapperType.NoWrap, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 100, LinqPerformanceCore.WrapperType.IEnumerable, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 100, LinqPerformanceCore.WrapperType.IReadOnlyCollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 100, LinqPerformanceCore.WrapperType.ICollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - //[Fact] - public void OrderBy_Performance() - { - RunTestGroup("OrderBy", col => col.OrderBy(o => -o)); - } - - //[Fact] - public void OrderByDescending_Performance() - { - RunTestGroup("OrderByDescending", col => col.OrderByDescending(o => o)); - } - - //[Fact] - public void OrderByThenBy_Performance() - { - RunTestGroup("OrderByThenBy", col => col.OrderBy(o => -o).ThenBy(o => o)); - } - } -} diff --git a/src/System.Linq/tests/Performance/Perf.Linq.cs b/src/System.Linq/tests/Performance/Perf.Linq.cs new file mode 100644 index 000000000000..71f178a6bab2 --- /dev/null +++ b/src/System.Linq/tests/Performance/Perf.Linq.cs @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license 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 class BaseClass + { + public int Value; + } + private class ChildClass : BaseClass + { + public int ChildValue; + } + + #endregion + + #region Perf Tests + + [Benchmark] + [MemberData("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("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("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("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("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("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("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("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("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("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("IterationSizeWrapperDataNoWrapper")] + public void Range(int size, int iteration) + { + Perf_LinqTestBase.Measure(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Range(0, size)); + } + + [Benchmark] + [MemberData("IterationSizeWrapperDataNoWrapper")] + public void Repeat(int size, int iteration) + { + Perf_LinqTestBase.Measure(1, iteration, Perf_LinqTestBase.WrapperType.NoWrap, col => Enumerable.Repeat(0, size)); + } + + [Benchmark] + [MemberData("IterationSizeWrapperData")] + public void Reverse(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) + { + Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Reverse()); + } + + [Benchmark] + [MemberData("IterationSizeWrapperData")] + public void Skip(int size, int iteration, Perf_LinqTestBase.WrapperType wrapType) + { + Perf_LinqTestBase.Measure(size, iteration, wrapType, col => col.Skip(1)); + } + + [Benchmark] + [MemberData("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("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("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("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("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); + } + + #endregion + } +} diff --git a/src/System.Linq/tests/Performance/LinqPerformanceCore.cs b/src/System.Linq/tests/Performance/Perf.LinqTestBase.cs similarity index 62% rename from src/System.Linq/tests/Performance/LinqPerformanceCore.cs rename to src/System.Linq/tests/Performance/Perf.LinqTestBase.cs index 8dac9b7f047f..c8a9fb8f85f2 100644 --- a/src/System.Linq/tests/Performance/LinqPerformanceCore.cs +++ b/src/System.Linq/tests/Performance/Perf.LinqTestBase.cs @@ -6,13 +6,14 @@ using System.Linq; using Xunit; using System.Diagnostics; +using Microsoft.Xunit.Performance; -namespace System.Linq.Tests.Performance +namespace System.Linq.Tests { /// /// Classes and methods to unify performance testing logic /// - public partial class LinqPerformanceCore + public partial class Perf_LinqTestBase { public class EnumerableWrapper : IEnumerable { @@ -106,97 +107,49 @@ public int IndexOf(T item) Collections.IEnumerator Collections.IEnumerable.GetEnumerator() { return ((IEnumerable)_array).GetEnumerator(); } } - // ============= - - [System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static TimeSpan MeasureIteration(IEnumerable source, int iterationCount, out int sideEffect) - { - int totalSize = 0; - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < iterationCount; i++) - { - foreach (var item in source) - totalSize++; - } - sw.Stop(); - - sideEffect = totalSize; - return sw.Elapsed; - } /// /// Measures the time of iteration over IEnumerable sequence /// /// Elements type /// Sequence /// Number of passes - /// Measured time - public static TimeSpan MeasureIteration(IEnumerable source, int iterationCount) + public static void MeasureIteration(IEnumerable source, int iterationCount) { - // WarmUp - int tmp = 0; - MeasureIteration(source, 1, out tmp); - - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - - return MeasureIteration(source, iterationCount, out tmp); - } - - - [System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static TimeSpan MeasureMaterializationToArray(IEnumerable source, int iterationCount, out int sideEffect) - { - int totalSize = 0; - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < iterationCount; i++) + foreach (var iteration in Benchmark.Iterations) { - var array = source.ToArray(); - totalSize += array.Length; + using (iteration.StartMeasurement()) + { + for (int i = 0; i < iterationCount; i++) + { + foreach (var item in source) + { } + } + } } - sw.Stop(); - - sideEffect = totalSize; - return sw.Elapsed; } + /// /// Measures the time of materialization of IEnumerable sequence to Array /// /// Elements type /// Sequence /// Number of passes - /// Measured time - public static TimeSpan MeasureMaterializationToArray(IEnumerable source, int iterationCount) - { - // WarmUp - int tmp = 0; - MeasureMaterializationToArray(source, 1, out tmp); - - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - - return MeasureMaterializationToArray(source, iterationCount, out tmp); - } - - - [System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static TimeSpan MeasureMaterializationToList(IEnumerable source, int iterationCount, out int sideEffect) + public static void MeasureMaterializationToArray(IEnumerable source, int iterationCount) { - int totalSize = 0; - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < iterationCount; i++) + foreach (var iteration in Benchmark.Iterations) { - var list = source.ToList(); - totalSize += list.Count; + using (iteration.StartMeasurement()) + { + for (int i = 0; i < iterationCount; i++) + { + source.ToArray(); + } + } } - sw.Stop(); - - sideEffect = totalSize; - return sw.Elapsed; } + /// /// Measures the time of materialization of IEnumerable sequence to List /// @@ -204,61 +157,43 @@ private static TimeSpan MeasureMaterializationToList(IEnumerable source, i /// Sequence /// Number of passes /// Measured time - public static TimeSpan MeasureMaterializationToList(IEnumerable source, int iterationCount) - { - // WarmUp - int tmp = 0; - MeasureMaterializationToList(source, 1, out tmp); - - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - - return MeasureMaterializationToList(source, iterationCount, out tmp); - } - - - - [System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static TimeSpan MeasureMaterializationToDictionary(IEnumerable source, int iterationCount, out int sideEffect) + public static void MeasureMaterializationToList(IEnumerable source, int iterationCount) { - int totalSize = 0; - int count = 0; - Stopwatch sw = Stopwatch.StartNew(); - for (int i = 0; i < iterationCount; i++) + foreach (var iteration in Benchmark.Iterations) { - var dictionary = source.ToDictionary(key => count++); - totalSize += dictionary.Count; + using (iteration.StartMeasurement()) + { + for (int i = 0; i < iterationCount; i++) + { + source.ToList(); + } + } } - sw.Stop(); - - sideEffect = totalSize; - return sw.Elapsed; } + /// /// Measures the time of materialization of IEnumerable sequence to Dictionary /// /// Elements type /// Sequence /// Number of passes - /// Measured time - public static TimeSpan MeasureMaterializationToDictionary(IEnumerable source, int iterationCount) + public static void MeasureMaterializationToDictionary(IEnumerable source, int iterationCount) { - // WarmUp - int tmp = 0; - MeasureMaterializationToDictionary(source, 1, out tmp); - - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - - return MeasureMaterializationToDictionary(source, iterationCount, out tmp); + 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, @@ -297,34 +232,28 @@ public static IEnumerable Wrap(T[] source, WrapperType wrapperKind) /// Main method to measure performance. /// Creates array of Int32 with length 'elementCount', wraps it by one of the wrapper, appies LINQ and measures materialization to Array /// - public static TimeSpan Measure(int elementCount, int iterationCount, WrapperType wrapperKind, Func, IEnumerable> applyLINQ) + 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); - return MeasureMaterializationToArray(linqExpr, iterationCount); + MeasureMaterializationToArray(linqExpr, iterationCount); } /// /// Main method to measure performance. /// Creates array of TSource with length 'elementCount', wraps it by one of the wrapper, appies LINQ and measures materialization to Array /// - public static TimeSpan Measure(int elementCount, int iterationCount, TSource defaultValue, WrapperType wrapperKind, Func, IEnumerable> applyLINQ) + 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); - return MeasureMaterializationToArray(linqExpr, iterationCount); + MeasureMaterializationToArray(linqExpr, iterationCount); } // =========== - - public static void WriteLine(string str, params object[] args) - { - System.Console.WriteLine(str, args); - Debug.WriteLine(str, args); - } } } diff --git a/src/System.Linq/tests/Performance/RangeRepeatPerf.cs b/src/System.Linq/tests/Performance/RangeRepeatPerf.cs deleted file mode 100644 index aff184edbdd0..000000000000 --- a/src/System.Linq/tests/Performance/RangeRepeatPerf.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class RangeRepeatPerf - { - //[Fact] - public void Range_Performance() - { - TimeSpan time = time = LinqPerformanceCore.Measure(1, 1000, LinqPerformanceCore.WrapperType.NoWrap, - col => Enumerable.Range(0, 1000000)); - LinqPerformanceCore.WriteLine("Range_Performance: {0}ms", time.TotalMilliseconds); - } - - - //[Fact] - public void Repeat_Performance() - { - TimeSpan time = time = LinqPerformanceCore.Measure(1, 1000, LinqPerformanceCore.WrapperType.NoWrap, - col => Enumerable.Repeat(0, 1000000)); - LinqPerformanceCore.WriteLine("Repeat_Performance: {0}ms", time.TotalMilliseconds); - } - - } -} diff --git a/src/System.Linq/tests/Performance/ReversePerf.cs b/src/System.Linq/tests/Performance/ReversePerf.cs deleted file mode 100644 index 115ad3cd5039..000000000000 --- a/src/System.Linq/tests/Performance/ReversePerf.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class ReversePerf - { - private void RunTestGroup(string description, Func, IEnumerable> linqApply) - { - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.NoWrap, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.IEnumerable, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.IReadOnlyCollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.ICollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - //[Fact] - public void Reverse_Performance() - { - RunTestGroup("Reverse", col => col.Reverse()); - } - } -} diff --git a/src/System.Linq/tests/Performance/SkipTakePerf.cs b/src/System.Linq/tests/Performance/SkipTakePerf.cs deleted file mode 100644 index 8a3d9c26b47c..000000000000 --- a/src/System.Linq/tests/Performance/SkipTakePerf.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class SkipTakePerf - { - private void RunTestGroup(string description, Func, IEnumerable> linqApply) - { - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.NoWrap, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.IEnumerable, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.IReadOnlyCollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.ICollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - //[Fact] - public void Skip_Performance() - { - RunTestGroup("Skip", col => col.Skip(1)); - } - - //[Fact] - public void Take_Performance() - { - RunTestGroup("Take", col => col.Take(1000000 - 1)); - } - - //[Fact] - public void SkipTake_Performance() - { - RunTestGroup("SkipTake", col => col.Skip(1).Take(1000000 - 2)); - } - } -} diff --git a/src/System.Linq/tests/Performance/ToArrayToListToDictionaryPerf.cs b/src/System.Linq/tests/Performance/ToArrayToListToDictionaryPerf.cs deleted file mode 100644 index 750e08b974ec..000000000000 --- a/src/System.Linq/tests/Performance/ToArrayToListToDictionaryPerf.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class ToArrayToListToDictionaryPerf - { - //[Fact] - public void ToArray_Performance() - { - int[] array = Enumerable.Range(0, 1000000).ToArray(); - - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.MeasureMaterializationToArray(array, 1000); - LinqPerformanceCore.WriteLine("ToArray_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToArray(new LinqPerformanceCore.EnumerableWrapper(array), 1000); - LinqPerformanceCore.WriteLine("ToArray_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToArray(new LinqPerformanceCore.ReadOnlyCollectionWrapper(array), 1000); - LinqPerformanceCore.WriteLine("ToArray_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToArray(new LinqPerformanceCore.CollectionWrapper(array), 1000); - LinqPerformanceCore.WriteLine("ToArray_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - // =========== - - //[Fact] - public void ToList_Performance() - { - int[] array = Enumerable.Range(0, 1000000).ToArray(); - - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.MeasureMaterializationToList(array, 1000); - LinqPerformanceCore.WriteLine("ToList_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToList(new LinqPerformanceCore.ReadOnlyCollectionWrapper(array), 1000); - LinqPerformanceCore.WriteLine("ToList_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToList(new LinqPerformanceCore.ReadOnlyCollectionWrapper(array), 1000); - LinqPerformanceCore.WriteLine("ToList_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToList(new LinqPerformanceCore.CollectionWrapper(array), 1000); - LinqPerformanceCore.WriteLine("ToList_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - // ============ - - //[Fact] - public void ToDictionary_Performance() - { - int[] array = Enumerable.Range(0, 1000000).ToArray(); - - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.MeasureMaterializationToDictionary(array, 100); - LinqPerformanceCore.WriteLine("ToDictionary_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToDictionary(new LinqPerformanceCore.EnumerableWrapper(array), 100); - LinqPerformanceCore.WriteLine("ToDictionary_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToDictionary(new LinqPerformanceCore.ReadOnlyCollectionWrapper(array), 100); - LinqPerformanceCore.WriteLine("ToDictionary_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.MeasureMaterializationToDictionary(new LinqPerformanceCore.CollectionWrapper(array), 100); - LinqPerformanceCore.WriteLine("ToDictionary_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - } -} diff --git a/src/System.Linq/tests/Performance/WhereSelectPerf.cs b/src/System.Linq/tests/Performance/WhereSelectPerf.cs deleted file mode 100644 index 7579aea58f89..000000000000 --- a/src/System.Linq/tests/Performance/WhereSelectPerf.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Diagnostics; - -namespace System.Linq.Tests.Performance -{ - // This is not a UnitTests - [Trait("Perf", "true")] - public class WhereSelectPerf - { - private void RunTestGroup(string description, Func, IEnumerable> linqApply) - { - TimeSpan time = TimeSpan.Zero; - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.NoWrap, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnRawArray_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.IEnumerable, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.IReadOnlyCollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds); - - time = LinqPerformanceCore.Measure(1000000, 1000, LinqPerformanceCore.WrapperType.ICollection, linqApply); - LinqPerformanceCore.WriteLine(description + "_OnCollection_Performance: {0}ms", time.TotalMilliseconds); - } - - - //[Fact] - public void Select_Performance() - { - RunTestGroup("Select", col => col.Select(o => o + 1)); - } - - //[Fact] - public void SelectSelect_Performance() - { - RunTestGroup("SelectSelect", col => col.Select(o => o + 1).Select(o => o - 1)); - } - - //[Fact] - public void Where_Performance() - { - RunTestGroup("Where", col => col.Where(o => o >= 0)); - } - - //[Fact] - public void WhereWhere_Performance() - { - RunTestGroup("WhereWhere", col => col.Where(o => o >= 0).Where(o => o >= -1)); - } - - //[Fact] - public void WhereSelect_Performance() - { - RunTestGroup("Where", col => col.Where(o => o >= 0).Select(o => o + 1)); - } - } -} diff --git a/src/System.Linq/tests/System.Linq.Tests.csproj b/src/System.Linq/tests/System.Linq.Tests.csproj index 14e3fcb09c2c..64f4693774da 100644 --- a/src/System.Linq/tests/System.Linq.Tests.csproj +++ b/src/System.Linq/tests/System.Linq.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -68,15 +68,13 @@ - - - - - - - - - + + + + + + Common\System\PerfUtils.cs + @@ -89,4 +87,4 @@ - \ No newline at end of file + diff --git a/src/System.Linq/tests/project.json b/src/System.Linq/tests/project.json index b198d83246b2..ab4cd9d9572b 100644 --- a/src/System.Linq/tests/project.json +++ b/src/System.Linq/tests/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.DotNet.xunit.performance": "1.0.0-*", "System.Collections": "4.0.10", "System.Globalization": "4.0.10", "System.Runtime": "4.0.20", diff --git a/src/System.Linq/tests/project.lock.json b/src/System.Linq/tests/project.lock.json index 8186d48589ca..49f8864d5c6c 100644 --- a/src/System.Linq/tests/project.lock.json +++ b/src/System.Linq/tests/project.lock.json @@ -3,6 +3,36 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.10", + "System.Diagnostics.Debug": "4.0.10", + "System.Diagnostics.Tracing": "4.0.20", + "System.Globalization": "4.0.10", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.0", + "System.Reflection": "4.0.10", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Tasks": "4.0.10", + "xunit.abstractions": "2.0.0", + "xunit.extensibility.core": "2.1.0", + "xunit.extensibility.execution": "2.1.0" + }, + "compile": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + }, + "runtime": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + } + }, "System.Collections/4.0.10": { "type": "package", "dependencies": { @@ -15,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -37,6 +67,18 @@ "lib/DNXCore50/System.Diagnostics.Debug.dll": {} } }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0" + }, + "compile": { + "ref/dotnet/System.Diagnostics.Tracing.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Diagnostics.Tracing.dll": {} + } + }, "System.Globalization/4.0.10": { "type": "package", "dependencies": { @@ -63,6 +105,42 @@ "lib/DNXCore50/System.IO.dll": {} } }, + "System.IO.FileSystem/4.0.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.10", + "System.IO": "4.0.10", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Resources.ResourceManager": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Text.Encoding": "4.0.10", + "System.Text.Encoding.Extensions": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Overlapped": "4.0.0", + "System.Threading.Tasks": "4.0.10" + }, + "compile": { + "ref/dotnet/System.IO.FileSystem.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.IO.FileSystem.dll": {} + } + }, + "System.IO.FileSystem.Primitives/4.0.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.20" + }, + "compile": { + "ref/dotnet/System.IO.FileSystem.Primitives.dll": {} + }, + "runtime": { + "lib/dotnet/System.IO.FileSystem.Primitives.dll": {} + } + }, "System.Linq/4.0.0": { "type": "package", "dependencies": { @@ -236,6 +314,19 @@ "lib/DNXCore50/System.Text.Encoding.dll": {} } }, + "System.Text.Encoding.Extensions/4.0.10": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0", + "System.Text.Encoding": "4.0.10" + }, + "compile": { + "ref/dotnet/System.Text.Encoding.Extensions.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Text.Encoding.Extensions.dll": {} + } + }, "System.Text.RegularExpressions/4.0.0": { "type": "package", "dependencies": { @@ -258,6 +349,19 @@ "lib/DNXCore50/System.Threading.dll": {} } }, + "System.Threading.Overlapped/4.0.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0", + "System.Runtime.Handles": "4.0.0" + }, + "compile": { + "ref/dotnet/System.Threading.Overlapped.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Threading.Overlapped.dll": {} + } + }, "System.Threading.Tasks/4.0.10": { "type": "package", "dependencies": { @@ -365,7 +469,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -393,6 +497,25 @@ } }, "libraries": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", + "files": [ + "lib/dotnet/xunit.performance.core.dll", + "lib/dotnet/xunit.performance.core.pdb", + "lib/dotnet/xunit.performance.core.XML", + "lib/dotnet/xunit.performance.execution.dotnet.dll", + "lib/dotnet/xunit.performance.execution.dotnet.pdb", + "lib/net46/xunit.performance.core.dll", + "lib/net46/xunit.performance.core.pdb", + "lib/net46/xunit.performance.core.XML", + "lib/net46/xunit.performance.execution.desktop.dll", + "lib/net46/xunit.performance.execution.desktop.pdb", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.nuspec" + ] + }, "System.Collections/4.0.10": { "type": "package", "serviceable": true, @@ -427,25 +550,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -483,6 +616,40 @@ "System.Diagnostics.Debug.nuspec" ] }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "serviceable": true, + "sha512": "gn/wexGHc35Fv++5L1gYHMY5g25COfiZ0PGrL+3PfwzoJd4X2LbTAm/U8d385SI6BKQBI/z4dQfvneS9J27+Tw==", + "files": [ + "lib/DNXCore50/System.Diagnostics.Tracing.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netcore50/System.Diagnostics.Tracing.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Diagnostics.Tracing.xml", + "ref/dotnet/es/System.Diagnostics.Tracing.xml", + "ref/dotnet/fr/System.Diagnostics.Tracing.xml", + "ref/dotnet/it/System.Diagnostics.Tracing.xml", + "ref/dotnet/ja/System.Diagnostics.Tracing.xml", + "ref/dotnet/ko/System.Diagnostics.Tracing.xml", + "ref/dotnet/ru/System.Diagnostics.Tracing.xml", + "ref/dotnet/System.Diagnostics.Tracing.dll", + "ref/dotnet/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hans/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hant/System.Diagnostics.Tracing.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "runtimes/win8-aot/lib/netcore50/System.Diagnostics.Tracing.dll", + "System.Diagnostics.Tracing.4.0.20.nupkg", + "System.Diagnostics.Tracing.4.0.20.nupkg.sha512", + "System.Diagnostics.Tracing.nuspec" + ] + }, "System.Globalization/4.0.10": { "type": "package", "sha512": "kzRtbbCNAxdafFBDogcM36ehA3th8c1PGiz8QRkZn8O5yMBorDHSK8/TGJPYOaCS5zdsGk0u9qXHnW91nqy7fw==", @@ -550,6 +717,71 @@ "System.IO.nuspec" ] }, + "System.IO.FileSystem/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "eo05SPWfG+54UA0wxgRIYOuOslq+2QrJLXZaJDDsfLXG15OLguaItW39NYZTqUb4DeGOkU4R0wpOLOW4ynMUDQ==", + "files": [ + "lib/DNXCore50/System.IO.FileSystem.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.dll", + "lib/netcore50/System.IO.FileSystem.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.IO.FileSystem.xml", + "ref/dotnet/es/System.IO.FileSystem.xml", + "ref/dotnet/fr/System.IO.FileSystem.xml", + "ref/dotnet/it/System.IO.FileSystem.xml", + "ref/dotnet/ja/System.IO.FileSystem.xml", + "ref/dotnet/ko/System.IO.FileSystem.xml", + "ref/dotnet/ru/System.IO.FileSystem.xml", + "ref/dotnet/System.IO.FileSystem.dll", + "ref/dotnet/System.IO.FileSystem.xml", + "ref/dotnet/zh-hans/System.IO.FileSystem.xml", + "ref/dotnet/zh-hant/System.IO.FileSystem.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "System.IO.FileSystem.4.0.0.nupkg", + "System.IO.FileSystem.4.0.0.nupkg.sha512", + "System.IO.FileSystem.nuspec" + ] + }, + "System.IO.FileSystem.Primitives/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "7pJUvYi/Yq3A5nagqCCiOw3+aJp3xXc/Cjr8dnJDnER3/6kX3LEencfqmXUcPl9+7OvRNyPMNhqsLAcMK6K/KA==", + "files": [ + "lib/dotnet/System.IO.FileSystem.Primitives.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.Primitives.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/es/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/fr/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/it/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/ja/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/ko/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/ru/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/System.IO.FileSystem.Primitives.dll", + "ref/dotnet/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/zh-hans/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/zh-hant/System.IO.FileSystem.Primitives.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.Primitives.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "System.IO.FileSystem.Primitives.4.0.0.nupkg", + "System.IO.FileSystem.Primitives.4.0.0.nupkg.sha512", + "System.IO.FileSystem.Primitives.nuspec" + ] + }, "System.Linq/4.0.0": { "type": "package", "serviceable": true, @@ -1018,6 +1250,39 @@ "System.Text.Encoding.nuspec" ] }, + "System.Text.Encoding.Extensions/4.0.10": { + "type": "package", + "sha512": "TZvlwXMxKo3bSRIcsWZLCIzIhLbvlz+mGeKYRZv/zUiSoQzGOwkYeBu6hOw2XPQgKqT0F4Rv8zqKdvmp2fWKYg==", + "files": [ + "lib/DNXCore50/System.Text.Encoding.Extensions.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netcore50/System.Text.Encoding.Extensions.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Text.Encoding.Extensions.xml", + "ref/dotnet/es/System.Text.Encoding.Extensions.xml", + "ref/dotnet/fr/System.Text.Encoding.Extensions.xml", + "ref/dotnet/it/System.Text.Encoding.Extensions.xml", + "ref/dotnet/ja/System.Text.Encoding.Extensions.xml", + "ref/dotnet/ko/System.Text.Encoding.Extensions.xml", + "ref/dotnet/ru/System.Text.Encoding.Extensions.xml", + "ref/dotnet/System.Text.Encoding.Extensions.dll", + "ref/dotnet/System.Text.Encoding.Extensions.xml", + "ref/dotnet/zh-hans/System.Text.Encoding.Extensions.xml", + "ref/dotnet/zh-hant/System.Text.Encoding.Extensions.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "runtimes/win8-aot/lib/netcore50/System.Text.Encoding.Extensions.dll", + "System.Text.Encoding.Extensions.4.0.10.nupkg", + "System.Text.Encoding.Extensions.4.0.10.nupkg.sha512", + "System.Text.Encoding.Extensions.nuspec" + ] + }, "System.Text.RegularExpressions/4.0.0": { "type": "package", "sha512": "D2CHm8LBIymJK9+1E3sn4cUEzMd6B+quQUrCGUluv9QFBNOdL3XqNu548QKeNplEXFOmF5aKXMxXbTrjbEUNMw==", @@ -1100,6 +1365,31 @@ "System.Threading.nuspec" ] }, + "System.Threading.Overlapped/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "X5LuQFhM5FTqaez3eXKJ9CbfSGZ7wj6j4hSVtxct3zmwQXLqG95qoWdvILcgN7xtrDOBIFtpiyDg0vmoI0jE2A==", + "files": [ + "lib/DNXCore50/System.Threading.Overlapped.dll", + "lib/net46/System.Threading.Overlapped.dll", + "lib/netcore50/System.Threading.Overlapped.dll", + "ref/dotnet/de/System.Threading.Overlapped.xml", + "ref/dotnet/es/System.Threading.Overlapped.xml", + "ref/dotnet/fr/System.Threading.Overlapped.xml", + "ref/dotnet/it/System.Threading.Overlapped.xml", + "ref/dotnet/ja/System.Threading.Overlapped.xml", + "ref/dotnet/ko/System.Threading.Overlapped.xml", + "ref/dotnet/ru/System.Threading.Overlapped.xml", + "ref/dotnet/System.Threading.Overlapped.dll", + "ref/dotnet/System.Threading.Overlapped.xml", + "ref/dotnet/zh-hans/System.Threading.Overlapped.xml", + "ref/dotnet/zh-hant/System.Threading.Overlapped.xml", + "ref/net46/System.Threading.Overlapped.dll", + "System.Threading.Overlapped.4.0.0.nupkg", + "System.Threading.Overlapped.4.0.0.nupkg.sha512", + "System.Threading.Overlapped.nuspec" + ] + }, "System.Threading.Tasks/4.0.10": { "type": "package", "serviceable": true, @@ -1251,20 +1541,21 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } }, "projectFileDependencyGroups": { "": [ + "Microsoft.DotNet.xunit.performance >= 1.0.0-*", "System.Collections >= 4.0.10", "System.Globalization >= 4.0.10", "System.Runtime >= 4.0.20", diff --git a/src/System.Numerics.Vectors/tests/Performance/Perf.Vector2.cs b/src/System.Numerics.Vectors/tests/Performance/Perf.Vector2.cs new file mode 100644 index 000000000000..98e58d87e412 --- /dev/null +++ b/src/System.Numerics.Vectors/tests/Performance/Perf.Vector2.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Xunit.Performance; +using Xunit; +using System.Numerics; +using System.Collections.Generic; + +namespace System.Numerics.Tests +{ + public class Perf_Vector2 + { + public static IEnumerable TestOperations() + { + foreach (Operations op in Enum.GetValues(typeof(Operations))) + yield return new object[] { op }; + } + + [Benchmark] + [MemberData("TestOperations")] + public void Operation(Operations operation) + { + Random rand = new Random(84329); + Vector2 v1 = new Vector2(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble())); + Vector2 v2 = new Vector2(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble())); + foreach (var iteration in Benchmark.Iterations) + using (iteration.StartMeasurement()) + ExecuteTest(operation, 1000000, v1, v2); + } + + public void ExecuteTest(Operations operation, int innerIterations, Vector2 v1, Vector2 v2) + { + Vector2 res; + switch (operation) + { + case Operations.Add_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; } + break; + case Operations.Add_Function: + for (int i = 0; i < innerIterations; i++) + { Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); Vector2.Add(v1, v2); } + break; + case Operations.Sub_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; } + break; + case Operations.Sub_Function: + for (int i = 0; i < innerIterations; i++) + { Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); Vector2.Subtract(v1, v2); } + break; + case Operations.Mul_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; } + break; + case Operations.Mul_Function: + for (int i = 0; i < innerIterations; i++) + { Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); Vector2.Multiply(v1, v2); } + break; + case Operations.Dot: + for (int i = 0; i < innerIterations; i++) + { Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); Vector2.Dot(v1, v2); } + break; + case Operations.SquareRoot: + for (int i = 0; i < innerIterations; i++) + { Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); Vector2.SquareRoot(v1); } + break; + case Operations.Length_Squared: + for (int i = 0; i < innerIterations; i++) + { v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); } + break; + case Operations.Normalize: + for (int i = 0; i < innerIterations; i++) + { Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); Vector2.Normalize(v1); } + break; + case Operations.Distance_Squared: + for (int i = 0; i < innerIterations; i++) + { Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); Vector2.DistanceSquared(v1, v2); } + break; + } + } + + public enum Operations + { + Add_Operator = 1, + Add_Function = 2, + Sub_Operator = 3, + Sub_Function = 4, + Mul_Operator = 5, + Mul_Function = 6, + Dot = 7, + SquareRoot = 8, + Length_Squared = 9, + Normalize = 10, + Distance_Squared = 11 + } + } +} diff --git a/src/System.Numerics.Vectors/tests/Performance/Perf.Vector3.cs b/src/System.Numerics.Vectors/tests/Performance/Perf.Vector3.cs new file mode 100644 index 000000000000..58fa5eb49286 --- /dev/null +++ b/src/System.Numerics.Vectors/tests/Performance/Perf.Vector3.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Xunit.Performance; +using Xunit; +using System.Numerics; +using System.Collections.Generic; + +namespace System.Numerics.Tests +{ + public class Perf_Vector3 + { + public static IEnumerable TestOperations() + { + foreach (Operations op in Enum.GetValues(typeof(Operations))) + yield return new object[] { op }; + } + + [Benchmark] + [MemberData("TestOperations")] + public void Operation(Operations operation) + { + Random rand = new Random(84329); + Vector3 v1 = new Vector3(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble())); + Vector3 v2 = new Vector3(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble())); + foreach (var iteration in Benchmark.Iterations) + using (iteration.StartMeasurement()) + ExecuteTest(operation, 1000000, v1, v2); + } + + public void ExecuteTest(Operations operation, int innerIterations, Vector3 v1, Vector3 v2) + { + Vector3 res; + switch (operation) + { + case Operations.Add_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; } + break; + case Operations.Add_Function: + for (int i = 0; i < innerIterations; i++) + { Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); Vector3.Add(v1, v2); } + break; + case Operations.Sub_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; } + break; + case Operations.Sub_Function: + for (int i = 0; i < innerIterations; i++) + { Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); Vector3.Subtract(v1, v2); } + break; + case Operations.Mul_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; } + break; + case Operations.Mul_Function: + for (int i = 0; i < innerIterations; i++) + { Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); Vector3.Multiply(v1, v2); } + break; + case Operations.Dot: + for (int i = 0; i < innerIterations; i++) + { Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); Vector3.Dot(v1, v2); } + break; + case Operations.SquareRoot: + for (int i = 0; i < innerIterations; i++) + { Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); Vector3.SquareRoot(v1); } + break; + case Operations.Length_Squared: + for (int i = 0; i < innerIterations; i++) + { v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); } + break; + case Operations.Normalize: + for (int i = 0; i < innerIterations; i++) + { Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); Vector3.Normalize(v1); } + break; + case Operations.Distance_Squared: + for (int i = 0; i < innerIterations; i++) + { Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); Vector3.DistanceSquared(v1, v2); } + break; + case Operations.Cross: + for (int i = 0; i < innerIterations; i++) + { Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); Vector3.Cross(v1, v2); } + break; + } + } + + public enum Operations + { + Add_Operator = 1, + Add_Function = 2, + Sub_Operator = 3, + Sub_Function = 4, + Mul_Operator = 5, + Mul_Function = 6, + Dot = 7, + SquareRoot = 8, + Length_Squared = 9, + Normalize = 10, + Distance_Squared = 11, + Cross = 12 + } + } +} diff --git a/src/System.Numerics.Vectors/tests/Performance/Perf.Vector4.cs b/src/System.Numerics.Vectors/tests/Performance/Perf.Vector4.cs new file mode 100644 index 000000000000..b14666ab9138 --- /dev/null +++ b/src/System.Numerics.Vectors/tests/Performance/Perf.Vector4.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Xunit.Performance; +using Xunit; +using System.Numerics; +using System.Collections.Generic; + +namespace System.Numerics.Tests +{ + public class Perf_Vector4 + { + public static IEnumerable TestOperations() + { + foreach (Operations op in Enum.GetValues(typeof(Operations))) + yield return new object[] { op }; + } + + [Benchmark] + [MemberData("TestOperations")] + public void Operation(Operations operation) + { + Random rand = new Random(84329); + Vector4 v1 = new Vector4(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble())); + Vector4 v2 = new Vector4(Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble()), Convert.ToSingle(rand.NextDouble())); + foreach (var iteration in Benchmark.Iterations) + using (iteration.StartMeasurement()) + ExecuteTest(operation, 1000000, v1, v2); + } + + public void ExecuteTest(Operations operation, int innerIterations, Vector4 v1, Vector4 v2) + { + Vector4 res; + switch (operation) + { + case Operations.Add_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; res = v1 + v2; } + break; + case Operations.Add_Function: + for (int i = 0; i < innerIterations; i++) + { Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); Vector4.Add(v1, v2); } + break; + case Operations.Sub_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; res = v1 - v2; } + break; + case Operations.Sub_Function: + for (int i = 0; i < innerIterations; i++) + { Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); Vector4.Subtract(v1, v2); } + break; + case Operations.Mul_Operator: + for (int i = 0; i < innerIterations; i++) + { res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; res = v1 * v2; } + break; + case Operations.Mul_Function: + for (int i = 0; i < innerIterations; i++) + { Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); Vector4.Multiply(v1, v2); } + break; + case Operations.Dot: + for (int i = 0; i < innerIterations; i++) + { Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); Vector4.Dot(v1, v2); } + break; + case Operations.SquareRoot: + for (int i = 0; i < innerIterations; i++) + { Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); Vector4.SquareRoot(v1); } + break; + case Operations.Length_Squared: + for (int i = 0; i < innerIterations; i++) + { v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); v1.LengthSquared(); } + break; + case Operations.Normalize: + for (int i = 0; i < innerIterations; i++) + { Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); Vector4.Normalize(v1); } + break; + case Operations.Distance_Squared: + for (int i = 0; i < innerIterations; i++) + { Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); Vector4.DistanceSquared(v1, v2); } + break; + } + } + + public enum Operations + { + Add_Operator = 1, + Add_Function = 2, + Sub_Operator = 3, + Sub_Function = 4, + Mul_Operator = 5, + Mul_Function = 6, + Dot = 7, + SquareRoot = 8, + Length_Squared = 9, + Normalize = 10, + Distance_Squared = 11 + } + } +} diff --git a/src/System.Numerics.Vectors/tests/System.Numerics.Vectors.Tests.csproj b/src/System.Numerics.Vectors/tests/System.Numerics.Vectors.Tests.csproj index 7c6bac1555aa..d3aa07a6d073 100644 --- a/src/System.Numerics.Vectors/tests/System.Numerics.Vectors.Tests.csproj +++ b/src/System.Numerics.Vectors/tests/System.Numerics.Vectors.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -39,6 +39,15 @@ + + + + + + + Common\System\PerfUtils.cs + + @@ -65,4 +74,4 @@ - \ No newline at end of file + diff --git a/src/System.Numerics.Vectors/tests/project.json b/src/System.Numerics.Vectors/tests/project.json index 49d48d6a9cc1..d113faf39a33 100644 --- a/src/System.Numerics.Vectors/tests/project.json +++ b/src/System.Numerics.Vectors/tests/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "Microsoft.DotNet.xunit.performance": "1.0.0-*", "System.Runtime": "4.0.20", "System.Runtime.Extensions": "4.0.10", "System.Resources.ResourceManager": "4.0.0", diff --git a/src/System.Numerics.Vectors/tests/project.lock.json b/src/System.Numerics.Vectors/tests/project.lock.json index 839b9f5958a5..aa249a6032d6 100644 --- a/src/System.Numerics.Vectors/tests/project.lock.json +++ b/src/System.Numerics.Vectors/tests/project.lock.json @@ -30,6 +30,36 @@ "lib/dotnet/Microsoft.CSharp.dll": {} } }, + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.10", + "System.Diagnostics.Debug": "4.0.10", + "System.Diagnostics.Tracing": "4.0.20", + "System.Globalization": "4.0.10", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.0", + "System.Reflection": "4.0.10", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Tasks": "4.0.10", + "xunit.abstractions": "2.0.0", + "xunit.extensibility.core": "2.1.0", + "xunit.extensibility.execution": "2.1.0" + }, + "compile": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + }, + "runtime": { + "lib/dotnet/xunit.performance.core.dll": {}, + "lib/dotnet/xunit.performance.execution.dotnet.dll": {} + } + }, "System.Collections/4.0.10": { "type": "package", "dependencies": { @@ -54,6 +84,18 @@ "lib/DNXCore50/System.Diagnostics.Debug.dll": {} } }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0" + }, + "compile": { + "ref/dotnet/System.Diagnostics.Tracing.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Diagnostics.Tracing.dll": {} + } + }, "System.Dynamic.Runtime/4.0.10": { "type": "package", "dependencies": { @@ -105,6 +147,42 @@ "lib/DNXCore50/System.IO.dll": {} } }, + "System.IO.FileSystem/4.0.0": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.10", + "System.IO": "4.0.10", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Resources.ResourceManager": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Text.Encoding": "4.0.10", + "System.Text.Encoding.Extensions": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Overlapped": "4.0.0", + "System.Threading.Tasks": "4.0.10" + }, + "compile": { + "ref/dotnet/System.IO.FileSystem.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.IO.FileSystem.dll": {} + } + }, + "System.IO.FileSystem.Primitives/4.0.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.20" + }, + "compile": { + "ref/dotnet/System.IO.FileSystem.Primitives.dll": {} + }, + "runtime": { + "lib/dotnet/System.IO.FileSystem.Primitives.dll": {} + } + }, "System.Linq/4.0.0": { "type": "package", "dependencies": { @@ -359,6 +437,19 @@ "lib/DNXCore50/System.Text.Encoding.dll": {} } }, + "System.Text.Encoding.Extensions/4.0.10": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0", + "System.Text.Encoding": "4.0.10" + }, + "compile": { + "ref/dotnet/System.Text.Encoding.Extensions.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Text.Encoding.Extensions.dll": {} + } + }, "System.Text.RegularExpressions/4.0.0": { "type": "package", "dependencies": { @@ -381,6 +472,19 @@ "lib/DNXCore50/System.Threading.dll": {} } }, + "System.Threading.Overlapped/4.0.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.0.0", + "System.Runtime.Handles": "4.0.0" + }, + "compile": { + "ref/dotnet/System.Threading.Overlapped.dll": {} + }, + "runtime": { + "lib/DNXCore50/System.Threading.Overlapped.dll": {} + } + }, "System.Threading.Tasks/4.0.10": { "type": "package", "dependencies": { @@ -488,7 +592,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -557,6 +661,25 @@ "ref/xamarinmac20/_._" ] }, + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { + "type": "package", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", + "files": [ + "lib/dotnet/xunit.performance.core.dll", + "lib/dotnet/xunit.performance.core.pdb", + "lib/dotnet/xunit.performance.core.XML", + "lib/dotnet/xunit.performance.execution.dotnet.dll", + "lib/dotnet/xunit.performance.execution.dotnet.pdb", + "lib/net46/xunit.performance.core.dll", + "lib/net46/xunit.performance.core.pdb", + "lib/net46/xunit.performance.core.XML", + "lib/net46/xunit.performance.execution.desktop.dll", + "lib/net46/xunit.performance.execution.desktop.pdb", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.nuspec" + ] + }, "System.Collections/4.0.10": { "type": "package", "serviceable": true, @@ -625,6 +748,40 @@ "System.Diagnostics.Debug.nuspec" ] }, + "System.Diagnostics.Tracing/4.0.20": { + "type": "package", + "serviceable": true, + "sha512": "gn/wexGHc35Fv++5L1gYHMY5g25COfiZ0PGrL+3PfwzoJd4X2LbTAm/U8d385SI6BKQBI/z4dQfvneS9J27+Tw==", + "files": [ + "lib/DNXCore50/System.Diagnostics.Tracing.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netcore50/System.Diagnostics.Tracing.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Diagnostics.Tracing.xml", + "ref/dotnet/es/System.Diagnostics.Tracing.xml", + "ref/dotnet/fr/System.Diagnostics.Tracing.xml", + "ref/dotnet/it/System.Diagnostics.Tracing.xml", + "ref/dotnet/ja/System.Diagnostics.Tracing.xml", + "ref/dotnet/ko/System.Diagnostics.Tracing.xml", + "ref/dotnet/ru/System.Diagnostics.Tracing.xml", + "ref/dotnet/System.Diagnostics.Tracing.dll", + "ref/dotnet/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hans/System.Diagnostics.Tracing.xml", + "ref/dotnet/zh-hant/System.Diagnostics.Tracing.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "runtimes/win8-aot/lib/netcore50/System.Diagnostics.Tracing.dll", + "System.Diagnostics.Tracing.4.0.20.nupkg", + "System.Diagnostics.Tracing.4.0.20.nupkg.sha512", + "System.Diagnostics.Tracing.nuspec" + ] + }, "System.Dynamic.Runtime/4.0.10": { "type": "package", "serviceable": true, @@ -727,6 +884,71 @@ "System.IO.nuspec" ] }, + "System.IO.FileSystem/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "eo05SPWfG+54UA0wxgRIYOuOslq+2QrJLXZaJDDsfLXG15OLguaItW39NYZTqUb4DeGOkU4R0wpOLOW4ynMUDQ==", + "files": [ + "lib/DNXCore50/System.IO.FileSystem.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.dll", + "lib/netcore50/System.IO.FileSystem.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.IO.FileSystem.xml", + "ref/dotnet/es/System.IO.FileSystem.xml", + "ref/dotnet/fr/System.IO.FileSystem.xml", + "ref/dotnet/it/System.IO.FileSystem.xml", + "ref/dotnet/ja/System.IO.FileSystem.xml", + "ref/dotnet/ko/System.IO.FileSystem.xml", + "ref/dotnet/ru/System.IO.FileSystem.xml", + "ref/dotnet/System.IO.FileSystem.dll", + "ref/dotnet/System.IO.FileSystem.xml", + "ref/dotnet/zh-hans/System.IO.FileSystem.xml", + "ref/dotnet/zh-hant/System.IO.FileSystem.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "System.IO.FileSystem.4.0.0.nupkg", + "System.IO.FileSystem.4.0.0.nupkg.sha512", + "System.IO.FileSystem.nuspec" + ] + }, + "System.IO.FileSystem.Primitives/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "7pJUvYi/Yq3A5nagqCCiOw3+aJp3xXc/Cjr8dnJDnER3/6kX3LEencfqmXUcPl9+7OvRNyPMNhqsLAcMK6K/KA==", + "files": [ + "lib/dotnet/System.IO.FileSystem.Primitives.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/System.IO.FileSystem.Primitives.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/es/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/fr/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/it/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/ja/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/ko/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/ru/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/System.IO.FileSystem.Primitives.dll", + "ref/dotnet/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/zh-hans/System.IO.FileSystem.Primitives.xml", + "ref/dotnet/zh-hant/System.IO.FileSystem.Primitives.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/System.IO.FileSystem.Primitives.dll", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "System.IO.FileSystem.Primitives.4.0.0.nupkg", + "System.IO.FileSystem.Primitives.4.0.0.nupkg.sha512", + "System.IO.FileSystem.Primitives.nuspec" + ] + }, "System.Linq/4.0.0": { "type": "package", "serviceable": true, @@ -1280,6 +1502,39 @@ "System.Text.Encoding.nuspec" ] }, + "System.Text.Encoding.Extensions/4.0.10": { + "type": "package", + "sha512": "TZvlwXMxKo3bSRIcsWZLCIzIhLbvlz+mGeKYRZv/zUiSoQzGOwkYeBu6hOw2XPQgKqT0F4Rv8zqKdvmp2fWKYg==", + "files": [ + "lib/DNXCore50/System.Text.Encoding.Extensions.dll", + "lib/MonoAndroid10/_._", + "lib/MonoTouch10/_._", + "lib/net46/_._", + "lib/netcore50/System.Text.Encoding.Extensions.dll", + "lib/xamarinios10/_._", + "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Text.Encoding.Extensions.xml", + "ref/dotnet/es/System.Text.Encoding.Extensions.xml", + "ref/dotnet/fr/System.Text.Encoding.Extensions.xml", + "ref/dotnet/it/System.Text.Encoding.Extensions.xml", + "ref/dotnet/ja/System.Text.Encoding.Extensions.xml", + "ref/dotnet/ko/System.Text.Encoding.Extensions.xml", + "ref/dotnet/ru/System.Text.Encoding.Extensions.xml", + "ref/dotnet/System.Text.Encoding.Extensions.dll", + "ref/dotnet/System.Text.Encoding.Extensions.xml", + "ref/dotnet/zh-hans/System.Text.Encoding.Extensions.xml", + "ref/dotnet/zh-hant/System.Text.Encoding.Extensions.xml", + "ref/MonoAndroid10/_._", + "ref/MonoTouch10/_._", + "ref/net46/_._", + "ref/xamarinios10/_._", + "ref/xamarinmac20/_._", + "runtimes/win8-aot/lib/netcore50/System.Text.Encoding.Extensions.dll", + "System.Text.Encoding.Extensions.4.0.10.nupkg", + "System.Text.Encoding.Extensions.4.0.10.nupkg.sha512", + "System.Text.Encoding.Extensions.nuspec" + ] + }, "System.Text.RegularExpressions/4.0.0": { "type": "package", "sha512": "D2CHm8LBIymJK9+1E3sn4cUEzMd6B+quQUrCGUluv9QFBNOdL3XqNu548QKeNplEXFOmF5aKXMxXbTrjbEUNMw==", @@ -1362,6 +1617,31 @@ "System.Threading.nuspec" ] }, + "System.Threading.Overlapped/4.0.0": { + "type": "package", + "serviceable": true, + "sha512": "X5LuQFhM5FTqaez3eXKJ9CbfSGZ7wj6j4hSVtxct3zmwQXLqG95qoWdvILcgN7xtrDOBIFtpiyDg0vmoI0jE2A==", + "files": [ + "lib/DNXCore50/System.Threading.Overlapped.dll", + "lib/net46/System.Threading.Overlapped.dll", + "lib/netcore50/System.Threading.Overlapped.dll", + "ref/dotnet/de/System.Threading.Overlapped.xml", + "ref/dotnet/es/System.Threading.Overlapped.xml", + "ref/dotnet/fr/System.Threading.Overlapped.xml", + "ref/dotnet/it/System.Threading.Overlapped.xml", + "ref/dotnet/ja/System.Threading.Overlapped.xml", + "ref/dotnet/ko/System.Threading.Overlapped.xml", + "ref/dotnet/ru/System.Threading.Overlapped.xml", + "ref/dotnet/System.Threading.Overlapped.dll", + "ref/dotnet/System.Threading.Overlapped.xml", + "ref/dotnet/zh-hans/System.Threading.Overlapped.xml", + "ref/dotnet/zh-hant/System.Threading.Overlapped.xml", + "ref/net46/System.Threading.Overlapped.dll", + "System.Threading.Overlapped.4.0.0.nupkg", + "System.Threading.Overlapped.4.0.0.nupkg.sha512", + "System.Threading.Overlapped.nuspec" + ] + }, "System.Threading.Tasks/4.0.10": { "type": "package", "serviceable": true, @@ -1513,20 +1793,21 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } }, "projectFileDependencyGroups": { "": [ + "Microsoft.DotNet.xunit.performance >= 1.0.0-*", "System.Runtime >= 4.0.20", "System.Runtime.Extensions >= 4.0.10", "System.Resources.ResourceManager >= 4.0.0", diff --git a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj index 6d7ed5585ccc..0603a04cad64 100644 --- a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj +++ b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj @@ -11,11 +11,6 @@ true true - - - v5.0 - - diff --git a/src/System.Runtime.Extensions/tests/project.lock.json b/src/System.Runtime.Extensions/tests/project.lock.json index 0ea73acd4847..27a6b7facc6a 100644 --- a/src/System.Runtime.Extensions/tests/project.lock.json +++ b/src/System.Runtime.Extensions/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -289,7 +289,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -465,7 +465,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -493,9 +493,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -507,8 +507,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -546,25 +546,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -1183,10 +1193,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -1198,8 +1208,8 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, @@ -1527,14 +1537,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Runtime/tests/Performance/Perf.DateTime.cs b/src/System.Runtime/tests/Performance/Perf.DateTime.cs index 88a35c820155..b2e5abb0deb1 100644 --- a/src/System.Runtime/tests/Performance/Perf.DateTime.cs +++ b/src/System.Runtime/tests/Performance/Perf.DateTime.cs @@ -21,6 +21,20 @@ public void GetNow() } } + [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() { @@ -43,7 +57,7 @@ public void op_Subtraction() DateTime date2 = new DateTime(1996, 12, 6, 13, 2, 0); foreach (var iteration in Benchmark.Iterations) using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) + 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; diff --git a/src/System.Runtime/tests/Performance/Perf.String.cs b/src/System.Runtime/tests/Performance/Perf.String.cs index 2c2df88e0176..afb1596523f7 100644 --- a/src/System.Runtime/tests/Performance/Perf.String.cs +++ b/src/System.Runtime/tests/Performance/Perf.String.cs @@ -26,7 +26,11 @@ public void GetChars(int 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(); testString.ToCharArray(); + } } [Benchmark] diff --git a/src/System.Runtime/tests/Performance/Perf.StringBuilder.cs b/src/System.Runtime/tests/Performance/Perf.StringBuilder.cs index 636bd536aaae..29b73f573da3 100644 --- a/src/System.Runtime/tests/Performance/Perf.StringBuilder.cs +++ b/src/System.Runtime/tests/Performance/Perf.StringBuilder.cs @@ -23,6 +23,24 @@ public void ctor() } } + [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)] diff --git a/src/System.Runtime/tests/Performance/Perf.Type.cs b/src/System.Runtime/tests/Performance/Perf.Type.cs index 6c8762a64733..a78917cfc362 100644 --- a/src/System.Runtime/tests/Performance/Perf.Type.cs +++ b/src/System.Runtime/tests/Performance/Perf.Type.cs @@ -13,7 +13,7 @@ public void GetTypeFromHandle() RuntimeTypeHandle type1 = typeof(int).TypeHandle; foreach (var iteration in Benchmark.Iterations) using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) + 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); @@ -29,7 +29,7 @@ public void op_Equality() Type type2 = typeof(string); foreach (var iteration in Benchmark.Iterations) using (iteration.StartMeasurement()) - for (int i = 0; i < 10000; i++) + 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; diff --git a/src/System.Runtime/tests/System.Runtime.Tests.csproj b/src/System.Runtime/tests/System.Runtime.Tests.csproj index cb2440d67ae9..49b948f469cd 100644 --- a/src/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/System.Runtime/tests/System.Runtime.Tests.csproj @@ -12,11 +12,6 @@ true 1718 - - - v5.0 - - diff --git a/src/System.Runtime/tests/project.lock.json b/src/System.Runtime/tests/project.lock.json index 39b3c203d8a2..426d8b443994 100644 --- a/src/System.Runtime/tests/project.lock.json +++ b/src/System.Runtime/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -289,7 +289,7 @@ "lib/DNXCore50/System.Runtime.InteropServices.dll": {} } }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.Runtime": "4.0.0" @@ -465,7 +465,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -493,9 +493,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -507,8 +507,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -546,25 +546,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -1183,10 +1193,10 @@ "System.Runtime.InteropServices.nuspec" ] }, - "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23401": { + "System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "SDIqmBVaUpbu7f6FJ2E2ZE43CXY+tsdFCsY+dqLCCZowAH0QCQGUKCflLPAa7OQIIft98CvOxWlRZCwiuPuGTg==", + "sha512": "BE5xuM8Lx1Jh2/fonWW6jIB0a6HgpiT+asK9rfdJSwDR7iDHmJ0vOXbreV+CTLOVX/xGDRogIIt50MsN36h0kg==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", @@ -1198,8 +1208,8 @@ "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg", - "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23401.nupkg.sha512", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg", + "System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23409.nupkg.sha512", "System.Runtime.InteropServices.RuntimeInformation.nuspec" ] }, @@ -1527,14 +1537,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Text.Encoding/tests/Performance/Perf.Encoding.cs b/src/System.Text.Encoding/tests/Performance/Perf.Encoding.cs index 224df7940863..d70c554d697d 100644 --- a/src/System.Text.Encoding/tests/Performance/Perf.Encoding.cs +++ b/src/System.Text.Encoding/tests/Performance/Perf.Encoding.cs @@ -4,29 +4,107 @@ using System.Text; using Xunit; using Microsoft.Xunit.Performance; +using System.Collections.Generic; -namespace System.Text.EncodingTests +namespace System.Text.Tests { public class Perf_Encoding { + public static IEnumerable EncodingSizeData() + { + int[] sizes = new int[] { 10000, 1000000 }; + string[] encs = new string[] { "utf-8", "ascii" }; + foreach (int size in sizes) + foreach (string enc in encs) + yield return new object[] { size, enc }; + } + [Benchmark] - [InlineData(1000)] - [InlineData(10000)] - [InlineData(100000)] - [InlineData(1000000)] - public void GetBytes_str(int size) + [MemberData("EncodingSizeData")] + public void GetBytes(int size, string encName) { - Encoding enc = Encoding.UTF8; + 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 < 100; i++) + 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("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("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("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("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/System.Text.Encoding/tests/System.Text.Encoding.Tests.csproj b/src/System.Text.Encoding/tests/System.Text.Encoding.Tests.csproj index b7b934275087..24caa030b339 100644 --- a/src/System.Text.Encoding/tests/System.Text.Encoding.Tests.csproj +++ b/src/System.Text.Encoding/tests/System.Text.Encoding.Tests.csproj @@ -9,11 +9,6 @@ System.Text.Encoding.Tests System.Text.Encoding.Tests - - - v5.0 - - diff --git a/src/System.Text.Encoding/tests/project.lock.json b/src/System.Text.Encoding/tests/project.lock.json index 4ce258fe7eae..eb9809d9ab80 100644 --- a/src/System.Text.Encoding/tests/project.lock.json +++ b/src/System.Text.Encoding/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -459,7 +459,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -487,9 +487,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -501,8 +501,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -1499,14 +1499,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Threading/tests/System.Threading.Tests.csproj b/src/System.Threading/tests/System.Threading.Tests.csproj index efa4674492dd..fd43c6b64fc4 100644 --- a/src/System.Threading/tests/System.Threading.Tests.csproj +++ b/src/System.Threading/tests/System.Threading.Tests.csproj @@ -8,11 +8,6 @@ System.Threading.Tests {33F5A50E-B823-4FDD-8571-365C909ACEAE} - - - v5.0 - - diff --git a/src/System.Threading/tests/project.lock.json b/src/System.Threading/tests/project.lock.json index 94fab6f91492..33e5d2620416 100644 --- a/src/System.Threading/tests/project.lock.json +++ b/src/System.Threading/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -45,7 +45,7 @@ "lib/DNXCore50/System.Collections.dll": {} } }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "dependencies": { "System.IO": "4.0.0", @@ -469,7 +469,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -497,9 +497,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -511,8 +511,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -550,25 +550,35 @@ "System.Collections.nuspec" ] }, - "System.Console/4.0.0-beta-23401": { + "System.Console/4.0.0-beta-23409": { "type": "package", "serviceable": true, - "sha512": "49zWKpJWl584fCuBYIRg68wk69e2+r5g7K8vlZRijrmXqiMe8Bx0FEap7Dc1rPhTYD06g72P2u5v8QfLLDh4bQ==", + "sha512": "dO1UdUadTRQDeU8n99Tabd//6X/yTdp8qDRaZoD7EITou4iqAY9IHRBBImx+9AUkSO0MTYeOcxSl1wcnu3u4gQ==", "files": [ "lib/MonoAndroid10/_._", "lib/MonoTouch10/_._", "lib/net46/System.Console.dll", "lib/xamarinios10/_._", "lib/xamarinmac20/_._", + "ref/dotnet/de/System.Console.xml", + "ref/dotnet/es/System.Console.xml", + "ref/dotnet/fr/System.Console.xml", + "ref/dotnet/it/System.Console.xml", + "ref/dotnet/ja/System.Console.xml", + "ref/dotnet/ko/System.Console.xml", + "ref/dotnet/ru/System.Console.xml", "ref/dotnet/System.Console.dll", + "ref/dotnet/System.Console.xml", + "ref/dotnet/zh-hans/System.Console.xml", + "ref/dotnet/zh-hant/System.Console.xml", "ref/MonoAndroid10/_._", "ref/MonoTouch10/_._", "ref/net46/System.Console.dll", "ref/xamarinios10/_._", "ref/xamarinmac20/_._", "runtime.json", - "System.Console.4.0.0-beta-23401.nupkg", - "System.Console.4.0.0-beta-23401.nupkg.sha512", + "System.Console.4.0.0-beta-23409.nupkg", + "System.Console.4.0.0-beta-23409.nupkg.sha512", "System.Console.nuspec" ] }, @@ -1531,14 +1541,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] } diff --git a/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlDocument.cs b/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlDocument.cs index 0978ac83ec39..546b606bbf9b 100644 --- a/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlDocument.cs +++ b/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlDocument.cs @@ -9,6 +9,8 @@ namespace XmlDocumentTests.XmlDocumentTests { public class Perf_XmlDocument { + private const int innerIterations = 10000; + [Benchmark] public void Create() { @@ -16,9 +18,12 @@ public void Create() { using (iteration.StartMeasurement()) { - new XmlDocument(); new XmlDocument(); new XmlDocument(); - new XmlDocument(); new XmlDocument(); new XmlDocument(); - new XmlDocument(); new XmlDocument(); new XmlDocument(); + 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(); + } } } } @@ -26,33 +31,30 @@ public void Create() [Benchmark] public void LoadXml() { + XmlDocument doc = new XmlDocument(); foreach (var iteration in Benchmark.Iterations) - { - // Setup - var doc = new XmlDocument(); - - // Actual perf testing using (iteration.StartMeasurement()) - doc.LoadXml(" text node two e1; text node three "); - } + 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) { - // Setup - var doc = new XmlDocument(); - doc.LoadXml(" text node two e1; text node three "); - - // Actual perf testing using (iteration.StartMeasurement()) { - 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; + 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/System.Xml.XmlDocument/tests/Performance/Perf.XmlNode.cs b/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlNode.cs index 980f91db95cb..35c899e877a7 100644 --- a/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlNode.cs +++ b/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlNode.cs @@ -9,23 +9,27 @@ 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) { - // Setup - XmlDocument doc = new XmlDocument(); - doc.LoadXml(""); - XmlNode node = doc.DocumentElement; - - // Actual perf testing using (iteration.StartMeasurement()) { - 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; + 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; + } } } } @@ -33,20 +37,22 @@ public void GetAttributes() [Benchmark] public void GetValue() { + // Setup string value; + var doc = new XmlDocument(); + doc.LoadXml(""); + XmlNode node = doc.DocumentElement; + foreach (var iteration in Benchmark.Iterations) { - // Setup - var doc = new XmlDocument(); - doc.LoadXml(""); - XmlNode node = doc.DocumentElement; - - // Actual perf testing using (iteration.StartMeasurement()) { - 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; + 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/System.Xml.XmlDocument/tests/Performance/Perf.XmlNodeList.cs b/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlNodeList.cs index 224cdba598e4..4a8a67e18a2c 100644 --- a/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlNodeList.cs +++ b/src/System.Xml.XmlDocument/tests/Performance/Perf.XmlNodeList.cs @@ -9,39 +9,41 @@ namespace XmlDocumentTests.XmlNodeListTests { public class Perf_XmlNodeList { + private const int innerIterations = 10000; + [Benchmark] public void Enumerator() { - foreach (var iteration in Benchmark.Iterations) - { - // Setup - var doc = new XmlDocument(); - doc.LoadXml(""); - XmlNodeList list = doc.DocumentElement.ChildNodes; + // Setup + var doc = new XmlDocument(); + doc.LoadXml(""); + XmlNodeList list = doc.DocumentElement.ChildNodes; - // Actual perf testing + foreach (var iteration in Benchmark.Iterations) using (iteration.StartMeasurement()) - foreach (var element in list) { } - } + 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) { - // Setup - var doc = new XmlDocument(); - doc.LoadXml(""); - XmlNodeList list = doc.DocumentElement.ChildNodes; - - // Actual perf testing using (iteration.StartMeasurement()) { - 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; + 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/System.Xml.XmlDocument/tests/System.Xml.XmlDocument.Tests.csproj b/src/System.Xml.XmlDocument/tests/System.Xml.XmlDocument.Tests.csproj index 6a9a0717073d..60c048faabf0 100644 --- a/src/System.Xml.XmlDocument/tests/System.Xml.XmlDocument.Tests.csproj +++ b/src/System.Xml.XmlDocument/tests/System.Xml.XmlDocument.Tests.csproj @@ -10,11 +10,6 @@ System.Xml.XmlDocument.Tests System.Xml.XmlDocument.UnitTests - - - v5.0 - - diff --git a/src/System.Xml.XmlDocument/tests/project.lock.json b/src/System.Xml.XmlDocument/tests/project.lock.json index 123a7522cd26..ea7e528de78f 100644 --- a/src/System.Xml.XmlDocument/tests/project.lock.json +++ b/src/System.Xml.XmlDocument/tests/project.lock.json @@ -3,7 +3,7 @@ "version": 1, "targets": { "DNXCore,Version=v5.0": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", "dependencies": { "System.Collections": "4.0.10", @@ -492,7 +492,7 @@ "lib/dotnet/xunit.execution.dotnet.dll": {} } }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "dependencies": { "System.Diagnostics.Debug": "4.0.10", @@ -520,9 +520,9 @@ } }, "libraries": { - "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0022": { + "Microsoft.DotNet.xunit.performance/1.0.0-alpha-build0023": { "type": "package", - "sha512": "uh4WpDAs7mW9aiMqcHojn1MEGNUND03qmSsWFyVApAcRQQ0ppCJvQ2sUGBdL1/8DB12NGzKizaGg0Tnd4PCnfA==", + "sha512": "7TOhATYXNVMF3HHGuM/WFHLt7r4uvFIUliplzIHsfL/KwxaHUbV6RI1f7EZRAioMbJI5520BGOOZ+9XIqtTQuA==", "files": [ "lib/dotnet/xunit.performance.core.dll", "lib/dotnet/xunit.performance.core.pdb", @@ -534,8 +534,8 @@ "lib/net46/xunit.performance.core.XML", "lib/net46/xunit.performance.execution.desktop.dll", "lib/net46/xunit.performance.execution.desktop.pdb", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg", - "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0022.nupkg.sha512", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg", + "Microsoft.DotNet.xunit.performance.1.0.0-alpha-build0023.nupkg.sha512", "Microsoft.DotNet.xunit.performance.nuspec" ] }, @@ -1548,14 +1548,14 @@ "xunit.extensibility.execution.nuspec" ] }, - "xunit.netcore.extensions/1.0.0-prerelease-00102": { + "xunit.netcore.extensions/1.0.0-prerelease-00105": { "type": "package", "serviceable": true, - "sha512": "YOLHpTXiw6lEGbsQ1uQ93BAPKiUtrj4l+Yr1+WGdZShfCtGc3Sq3R9dISIHM49znLo+qDcnmo2oMGJdVZ9YTVg==", + "sha512": "EnnGcy9rmSdQ8izHWvYSYVyjQGhbeFH7JeM/L35ZrrPGtYvq5XD3hc1cJPCs+43mXdF9cdqhkt5uTlXYzC+Z8g==", "files": [ "lib/dotnet/Xunit.NetCore.Extensions.dll", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg", - "xunit.netcore.extensions.1.0.0-prerelease-00102.nupkg.sha512", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg", + "xunit.netcore.extensions.1.0.0-prerelease-00105.nupkg.sha512", "xunit.netcore.extensions.nuspec" ] }