Skip to content

Commit 37a562b

Browse files
DrewScogginsCopilot
andcommitted
Propagate exit codes from RunAsync in Akade, ImageSharp, bepuphysics2
Capture the summaries returned by BenchmarkSwitcher.RunAsync and return summaries.ToExitCode() so CI can detect benchmark failures and critical validation errors via a non-zero process exit code. Addresses Copilot review comments on PR #5227. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0e00497 commit 37a562b

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/benchmarks/real-world/Akade.IndexedSet.Benchmarks/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
// Use RunAsync (not Run) so BDN does not install its single-threaded
77
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
8-
await BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).RunAsync(args, RecommendedConfig.Create(
8+
var summaries = await BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).RunAsync(args, RecommendedConfig.Create(
99
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location)!, "BenchmarkDotNet.Artifacts")),
1010
mandatoryCategories: ImmutableHashSet.Create(Categories.AkadeIndexedSet)))
11-
.ConfigureAwait(false);
11+
.ConfigureAwait(false);
12+
return summaries.ToExitCode();

src/benchmarks/real-world/ImageSharp/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ public class Program
1919
/// </param>
2020
// Use RunAsync (not Run) so BDN does not install its single-threaded
2121
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
22-
public static async Task Main(string[] args)
22+
public static async Task<int> Main(string[] args)
2323
{
24-
await BenchmarkSwitcher
24+
var summaries = await BenchmarkSwitcher
2525
.FromAssembly(typeof(Program).Assembly)
2626
.RunAsync(args, RecommendedConfig.Create(
2727
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
2828
mandatoryCategories: ImmutableHashSet.Create(Categories.ImageSharp)))
2929
.ConfigureAwait(false);
30+
return summaries.ToExitCode();
3031
}
3132
}
3233
}

src/benchmarks/real-world/bepuphysics2/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ public class BepuPhysics2Benchmarks
99
{
1010
// Use RunAsync (not Run) so BDN does not install its single-threaded
1111
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
12-
public static async Task Main(string[] args)
12+
public static async Task<int> Main(string[] args)
1313
{
14-
await BenchmarkSwitcher
14+
var summaries = await BenchmarkSwitcher
1515
.FromAssembly(typeof(BepuPhysics2Benchmarks).Assembly)
1616
.RunAsync(args, RecommendedConfig.Create(
1717
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(BepuPhysics2Benchmarks).Assembly.Location), "BenchmarkDotNet.Artifacts")),
1818
mandatoryCategories: ImmutableHashSet.Create(Categories.BepuPhysics)))
1919
.ConfigureAwait(false);
20+
return summaries.ToExitCode();
2021
}
2122
}

0 commit comments

Comments
 (0)