From 05e1bdbe6d8161a20da1e9ccab58b2a4b60b5a56 Mon Sep 17 00:00:00 2001 From: Peter Liljenberg Date: Fri, 23 Nov 2018 10:50:48 +0100 Subject: [PATCH 1/2] Fix bug in the performance test and document how to run it in README.md. --- README.md | 9 +++++++++ test/coverlet.core.performancetest/PerformanceTest.cs | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5c1196511..2b1806c35 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,15 @@ This will result in the following: These steps must be followed before you attempt to open the solution in an IDE (e.g. Visual Studio, Rider) for all projects to be loaded successfully. +### Performance testing + +There is a performance test for the hit counting instrumentation in the test project `coverlet.core.performancetest`. Build the project with the msbuild step above and then run: + + dotnet test -p:CollectCoverage=true test/coverlet.core.performancetest/ + +The duration of the test can be tweaked by changing the number of iterations in the `[InlineData]` in the `PerformanceTest` class. + + ## Code of Conduct This project enforces a code of conduct in line with the contributor covenant. See [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details. diff --git a/test/coverlet.core.performancetest/PerformanceTest.cs b/test/coverlet.core.performancetest/PerformanceTest.cs index 57beb4608..0b97fd8bf 100644 --- a/test/coverlet.core.performancetest/PerformanceTest.cs +++ b/test/coverlet.core.performancetest/PerformanceTest.cs @@ -9,7 +9,7 @@ namespace coverlet.core.performancetest /// Test the performance of coverlet by running a unit test that calls a reasonably big and complex test class. /// Enable the test, compile, then run the test in the command line: /// - /// dotnet test -p:CollectCoverage=true -p:CoverletOutputFormat=opencover test/coverlet.core.performancetest/ + /// dotnet test -p:CollectCoverage=true test/coverlet.core.performancetest/ /// /// public class PerformanceTest @@ -20,11 +20,12 @@ public void TestPerformance(int iterations) { var big = new BigClass(); - List tasks = new List(); + var tasks = new List(); for (var i = 0; i < iterations; i++) { - tasks.Add(Task.Run(() => big.Do(i))); + var j = i; + tasks.Add(Task.Run(() => big.Do(j))); } Task.WaitAll(tasks.ToArray()); From 425536962f9aaa75c4106791077ce332c4741355 Mon Sep 17 00:00:00 2001 From: Peter Liljenberg Date: Fri, 23 Nov 2018 14:29:14 +0100 Subject: [PATCH 2/2] Use Windows-style parameters to be consistent with other command examples --- README.md | 2 +- test/coverlet.core.performancetest/PerformanceTest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b1806c35..4bd00fc08 100644 --- a/README.md +++ b/README.md @@ -391,7 +391,7 @@ These steps must be followed before you attempt to open the solution in an IDE ( There is a performance test for the hit counting instrumentation in the test project `coverlet.core.performancetest`. Build the project with the msbuild step above and then run: - dotnet test -p:CollectCoverage=true test/coverlet.core.performancetest/ + dotnet test /p:CollectCoverage=true test/coverlet.core.performancetest/ The duration of the test can be tweaked by changing the number of iterations in the `[InlineData]` in the `PerformanceTest` class. diff --git a/test/coverlet.core.performancetest/PerformanceTest.cs b/test/coverlet.core.performancetest/PerformanceTest.cs index 0b97fd8bf..8bad420b8 100644 --- a/test/coverlet.core.performancetest/PerformanceTest.cs +++ b/test/coverlet.core.performancetest/PerformanceTest.cs @@ -9,7 +9,7 @@ namespace coverlet.core.performancetest /// Test the performance of coverlet by running a unit test that calls a reasonably big and complex test class. /// Enable the test, compile, then run the test in the command line: /// - /// dotnet test -p:CollectCoverage=true test/coverlet.core.performancetest/ + /// dotnet test /p:CollectCoverage=true test/coverlet.core.performancetest/ /// /// public class PerformanceTest