Skip to content

Fix bug in the performance test and document how to run it in README.md. #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions test/coverlet.core.performancetest/PerformanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/// <code>
/// dotnet test -p:CollectCoverage=true -p:CoverletOutputFormat=opencover test/coverlet.core.performancetest/
/// dotnet test /p:CollectCoverage=true test/coverlet.core.performancetest/
/// </code>
/// </summary>
public class PerformanceTest
Expand All @@ -20,11 +20,12 @@ public void TestPerformance(int iterations)
{
var big = new BigClass();

List<Task> tasks = new List<Task>();
var tasks = new List<Task>();

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());
Expand Down