From aa6ebd68e55f263c64b934cb0c4c0892907515fa Mon Sep 17 00:00:00 2001 From: Erwin van der Valk Date: Tue, 24 Jun 2025 08:52:25 +0200 Subject: [PATCH] shorter writing of benchmark setup (#2063) --- .../Bff.Benchmarks/BenchmarkBase.cs | 28 ++++++++++++++++++- bff/performance/Bff.Benchmarks/Program.cs | 6 ++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bff/performance/Bff.Benchmarks/BenchmarkBase.cs b/bff/performance/Bff.Benchmarks/BenchmarkBase.cs index e61cd1846..dd08c81de 100644 --- a/bff/performance/Bff.Benchmarks/BenchmarkBase.cs +++ b/bff/performance/Bff.Benchmarks/BenchmarkBase.cs @@ -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); + } +} diff --git a/bff/performance/Bff.Benchmarks/Program.cs b/bff/performance/Bff.Benchmarks/Program.cs index 3de9e9e57..a974b1722 100644 --- a/bff/performance/Bff.Benchmarks/Program.cs +++ b/bff/performance/Bff.Benchmarks/Program.cs @@ -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());