using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; namespace Just.PreciseMath.Benchmarks; internal static class Program { private static int Main(string[] args) { BenchmarkSwitcher switcher = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly); // Only these standalone discovery/help forms intentionally produce no reports. if (args is ["--list", "flat" or "tree"] or ["--help"] or ["-h"]) { switcher.Run(args); return 0; } Summary[] summaries = switcher.Run(args.Length == 0 ? ["--filter", "*"] : args).ToArray(); // BenchmarkDotNet can return normally after validation, build, or execution // failures. Do not let CI mistake an empty or failed run for a passing smoke test. if (summaries.Length == 0 || summaries.Any(summary => summary.HasCriticalValidationErrors || summary.Reports.Length == 0 || summary.Reports.Any(report => !report.Success || report.ResultStatistics is null))) { Console.Error.WriteLine("Benchmark run failed or produced no measurements."); return 1; } return 0; } }