/
PerformanceTest.cs
33 lines (29 loc) · 1007 Bytes
/
PerformanceTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using coverlet.testsubject;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
namespace coverlet.core.performancetest
{
/// <summary>
/// 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/
/// </code>
/// </summary>
public class PerformanceTest
{
[Theory(Skip = "Only enabled when explicitly testing performance.")]
[InlineData(150)]
public void TestPerformance(int iterations)
{
var big = new BigClass();
List<Task> tasks = new List<Task>();
for (var i = 0; i < iterations; i++)
{
tasks.Add(Task.Run(() => big.Do(i)));
}
Task.WaitAll(tasks.ToArray());
}
}
}