Skip to content

Commit 485e06b

Browse files
committed
add Exporters
1 parent 2b0fcef commit 485e06b

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

test/coverlet.core.benchmark.tests/HowTo.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ Coverlet.core.benchmark uses [BenchmarkDotNet](https://github.com/dotnet/Benchma
66
- Make sure you have the latest version of the .NET SDK installed
77
- Make sure you have the latest version of the BenchmarkDotNet package installed
88

9-
Use a terminal and navigate to the `artifacts\bin\coverlet.core.benchmark.tests\release` directory. Then run the following command:
9+
Use a terminal and run the following commands:
1010

1111
```bash
12+
dotnet build test/coverlet.core.benchmark.tests -c release
13+
cd artifacts/bin/coverlet.core.benchmark.tests/release
1214
coverlet.core.benchmark.tests.exe
1315
```
1416
> [!TIP]
@@ -31,6 +33,11 @@ results\BenchmarkRun-joined-2025-04-11-08-55-34-report.html
3133
> This should be done for every coverlet release to avoid performance degradations.
3234
3335

36+
## Additional information
37+
- [BenchmarkDotNet](https://benchmarkdotnet.org)
38+
- [Analyze BenchmarkDotNet data in Visual Studio](https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-with-benchmark-dotnet)
39+
- [.NET benchmarking and profiling for beginners](https://medium.com/ingeniouslysimple/net-benchmarking-and-profiling-for-beginners-62462e1e9a19)
40+
3441
<blockquote>
3542

3643
## Coverlet 6.0.0

test/coverlet.core.benchmark.tests/InstrumenterBenchmarks.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
// Copyright (c) Toni Solarin-Sodara
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using System.IO;
5+
using BenchmarkDotNet.Attributes;
6+
using Coverlet.Core;
47
using Coverlet.Core.Abstractions;
58
using Coverlet.Core.Helpers;
6-
using Coverlet.Core.Symbols;
7-
8-
using BenchmarkDotNet.Attributes;
99
using Coverlet.Core.Instrumentation;
10-
using Coverlet.Core;
11-
using System.IO;
10+
using Coverlet.Core.Symbols;
1211
using Moq;
1312

1413
namespace coverlet.core.benchmark.tests
1514
{
16-
[MemoryDiagnoser]
1715
public class InstrumenterBenchmarks
18-
{
16+
{
1917
Mock<ILogger> _mockLogger;
2018
Mock<FileSystem> _partialMockFileSystem;
2119
readonly string[] _files = new[]
@@ -29,12 +27,6 @@ public class InstrumenterBenchmarks
2927
CoverageParameters _parameters;
3028
InstrumentationHelper _instrumentationHelper;
3129

32-
//[GlobalSetup(Target = nameof(InstrumenterBenchmarks))]
33-
//public void InstrumenterBenchmarkSetup()
34-
//{
35-
36-
//}
37-
3830
[GlobalCleanup]
3931
public void IterationCleanup()
4032
{

test/coverlet.core.benchmark.tests/Program.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using BenchmarkDotNet.Configs;
5+
using BenchmarkDotNet.Diagnosers;
6+
using BenchmarkDotNet.Exporters;
7+
using BenchmarkDotNet.Exporters.Csv;
8+
using BenchmarkDotNet.Exporters.Json;
9+
using BenchmarkDotNet.Exporters.Xml;
510
using BenchmarkDotNet.Jobs;
611
using BenchmarkDotNet.Running;
712
using BenchmarkDotNet.Toolchains.InProcess.NoEmit;
@@ -15,18 +20,27 @@ public static void Main(string[] args)
1520
{
1621

1722
var config = DefaultConfig.Instance
18-
.WithOptions(ConfigOptions.JoinSummary)
19-
.AddJob(Job
20-
.ShortRun
21-
.WithLaunchCount(1)
22-
.WithToolchain(InProcessNoEmitToolchain.Instance));
23+
.WithOptions(ConfigOptions.JoinSummary)
24+
.AddJob(Job
25+
.ShortRun
26+
.WithLaunchCount(1)
27+
.WithToolchain(InProcessNoEmitToolchain.Instance))
28+
.AddExporter(CsvExporter.Default)
29+
.AddExporter(CsvMeasurementsExporter.Default)
30+
.AddExporter(RPlotExporter.Default)
31+
.AddExporter(HtmlExporter.Default)
32+
.AddExporter(MarkdownExporter.GitHub)
33+
.AddExporter(JsonExporter.Default)
34+
.AddExporter(XmlExporter.Default)
35+
.AddDiagnoser(MemoryDiagnoser.Default)
36+
;
2337
var summary = BenchmarkRunner.Run(new[]{
2438
BenchmarkConverter.TypeToBenchmarks( typeof(CoverageBenchmarks), config),
2539
BenchmarkConverter.TypeToBenchmarks( typeof(InstrumenterBenchmarks), config)
2640
});
2741

28-
// Use this to select benchmarks from the console:
29-
//var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
42+
// Use this to select benchmarks from the console and execute with additional options e.g. 'coverlet.core.benchmark.tests.exe --profiler EP'
43+
//var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
3044
}
3145
}
3246
}

0 commit comments

Comments
 (0)