dotnet / dotnet/BenchmarkDotNet

Custom sinks

Open
#252 6 comments 2 reactions 0 assignees View on GitHub
enhancement help wanted up-for-grabs
Dominant language
C#
Stars
11.5k
Forks
1.1k
Avg merge
4d 11h
Merged PRs (30d)
11

Description

It is nice to put the results from benchmark runs in version control so that perf can be tracked over time.
Currently I hack it like this:

``` c#
using System.Collections.Generic;
using System.IO;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;

public class Program
{
private static readonly string DesinationDirectory = System.IO.Path.Combine(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent.FullName, "Results");

public static void Main()
{
foreach (var summary in RunAll())
{
CopyResult(summary.Title);
}
}

private static IEnumerable RunAll()
{
ClearAllResults();
var switcher = new BenchmarkSwitcher(typeof(Program).Assembly);
var summaries = switcher.Run(new[] { "*" });
return summaries;
}

private static IEnumerable RunSingle()
{
var summaries = new[] { BenchmarkRunner.Run() };
return summaries;
}

private static void CopyResult(string name)
{
#if DEBUG
#else
var sourceFileName = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "BenchmarkDotNet.Artifacts", "results", name + "-report-github.md");
System.IO.Directory.CreateDirectory(DesinationDirectory);
var destinationFileName = System.IO.Path.Combine(DesinationDirectory, name + ".md");
File.Copy(sourceFileName, destinationFileName, true);
#endif
}

private static void ClearAllResults()
{
if (Directory.Exists(DesinationDirectory))
{
foreach (var resultFile in Directory.EnumerateFiles(DesinationDirectory, "*.md"))
{
File.Delete(resultFile);
}
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.