Catalog/MaddoShared.Benchmarks/Program.cs

35 lines
1.3 KiB
C#
Raw Permalink Normal View History

using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
using System;
using System.Linq;
namespace MaddoShared.Benchmarks;
internal class Program
{
static void Main(string[] args)
{
// Check if --job argument is provided
bool hasJobArg = args.Any(a => a.Contains("--job"));
if (hasJobArg)
{
Console.WriteLine("Note: Overriding --job argument to use InProcess toolchain");
Console.WriteLine("This is required to avoid net10.0 vs net10.0-windows compatibility issues.");
Console.WriteLine();
// Remove --job arguments and add our own InProcess config
args = args.Where(a => !a.StartsWith("--job") && a != "dry" && a != "short").ToArray();
}
// Create configuration that always uses InProcess toolchain
var config = DefaultConfig.Instance
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
.WithOptions(ConfigOptions.KeepBenchmarkFiles);
// Run benchmarks - each class has [Config(typeof(InProcessConfig))] which provides InProcess toolchain
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
}
}