shorter writing of benchmark setup (#2063)

This commit is contained in:
Erwin van der Valk 2025-06-24 08:52:25 +02:00 committed by GitHub
parent 346cb75d43
commit aa6ebd68e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 5 deletions

View file

@ -2,11 +2,37 @@
// See LICENSE in the project root for license information.
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using Perfolizer.Horology;
using Perfolizer.Metrology;
namespace Bff.Benchmarks;
[ShortRunJob]
[Config(typeof(BenchmarkConfig))]
public class BenchmarkBase
{
}
public class BenchmarkConfig : ManualConfig
{
public BenchmarkConfig()
{
var exporter = new CsvExporter(
CsvSeparator.CurrentCulture,
new SummaryStyle(
cultureInfo: System.Globalization.CultureInfo.InvariantCulture,
printUnitsInHeader: false,
printUnitsInContent: false,
timeUnit: TimeUnit.Microsecond,
sizeUnit: SizeUnit.KB
));
AddJob(Job.ShortRun);
AddExporter(exporter);
}
}

View file

@ -1,10 +1,8 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;
public class Program
{
static void Main(string[] args) => BenchmarkRunner.Run(typeof(Program).Assembly);
}
BenchmarkRunner.Run(typeof(Program).Assembly, ManualConfig.CreateMinimumViable());