You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
You should add the `Benchmark.Net` package to your test project and configure your tests according to the [Getting Started](https://benchmarkdotnet.org/articles/guides/getting-started.html) docs. A simple test file might look like
18
+
19
+
20
+
```csharp
21
+
usingSystem;
22
+
usingSystem.Security.Cryptography;
23
+
usingBenchmarkDotNet.Attributes;
24
+
usingBenchmarkDotNet.Running;
25
+
26
+
namespaceMyBenchmarks
27
+
{
28
+
[JsonExporterAttribute.Full]
29
+
[JsonExporterAttribute.FullCompressed]
30
+
publicclassMd5VsSha256
31
+
{
32
+
privateconstintN=10000;
33
+
privatereadonlybyte[] data;
34
+
35
+
privatereadonlySHA256sha256=SHA256.Create();
36
+
privatereadonlyMD5md5=MD5.Create();
37
+
38
+
publicMd5VsSha256()
39
+
{
40
+
data=newbyte[N];
41
+
newRandom(42).NextBytes(data);
42
+
}
43
+
44
+
[Benchmark]
45
+
publicbyte[] Sha256() =>sha256.ComputeHash(data);
46
+
47
+
[Benchmark]
48
+
publicbyte[] Md5() =>md5.ComputeHash(data);
49
+
}
50
+
51
+
publicclassProgram
52
+
{
53
+
publicstaticvoidMain(string[] args)
54
+
{
55
+
varsummary=BenchmarkRunner.Run<Md5VsSha256>();
56
+
}
57
+
}
58
+
}
59
+
```
60
+
61
+
You can then run the tests using `dotnet run`. It's _very_ important that you ensure the JSON exporter is configured. You can do this by adding at least one of the exporter attributes in the example above, or by using the `BenchmarkSwitcher` type to run your tests, passing in your `args`, and using `--exporters json` from the command line.
62
+
63
+
## Process benchmark results
64
+
65
+
Store the benchmark results with step using the action. Please set `benchmarkdotnet` to `tool` input.
66
+
67
+
By default, Benchmark.Net will output results files to the current directory in a structure like:
68
+
69
+
```
70
+
BenchmarkDotNet.Artifacts
71
+
├── Sample.Benchmarks-20200529-153703.log
72
+
├── Sample.Benchmarks-20200529-153729.log
73
+
└── results
74
+
├── Sample.Benchmarks-report-full-compressed.json
75
+
├── Sample.Benchmarks-report-github.md
76
+
├── Sample.Benchmarks-report.csv
77
+
└── Sample.Benchmarks-report.html
78
+
```
79
+
80
+
You want to get the path of the `-report-full-compressed.json` report for use with this action. Once you have both pieces of data, use the action like so, replacing the output file path with your own path.
0 commit comments