Skip to content

Commit 3454f21

Browse files
authored
Merge pull request #248 from petli/bug-in-performance-test
Fix bug in the performance test and document how to run it in README.md.
2 parents 2ccb9b4 + 4255369 commit 3454f21

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@ This will result in the following:
387387
388388
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.
389389
390+
### Performance testing
391+
392+
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:
393+
394+
dotnet test /p:CollectCoverage=true test/coverlet.core.performancetest/
395+
396+
The duration of the test can be tweaked by changing the number of iterations in the `[InlineData]` in the `PerformanceTest` class.
397+
398+
390399
## Code of Conduct
391400
392401
This project enforces a code of conduct in line with the contributor covenant. See [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.

test/coverlet.core.performancetest/PerformanceTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace coverlet.core.performancetest
99
/// Test the performance of coverlet by running a unit test that calls a reasonably big and complex test class.
1010
/// Enable the test, compile, then run the test in the command line:
1111
/// <code>
12-
/// dotnet test -p:CollectCoverage=true -p:CoverletOutputFormat=opencover test/coverlet.core.performancetest/
12+
/// dotnet test /p:CollectCoverage=true test/coverlet.core.performancetest/
1313
/// </code>
1414
/// </summary>
1515
public class PerformanceTest
@@ -20,11 +20,12 @@ public void TestPerformance(int iterations)
2020
{
2121
var big = new BigClass();
2222

23-
List<Task> tasks = new List<Task>();
23+
var tasks = new List<Task>();
2424

2525
for (var i = 0; i < iterations; i++)
2626
{
27-
tasks.Add(Task.Run(() => big.Do(i)));
27+
var j = i;
28+
tasks.Add(Task.Run(() => big.Do(j)));
2829
}
2930

3031
Task.WaitAll(tasks.ToArray());

0 commit comments

Comments
 (0)