BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Running with .Net 6/7 Mono JIT
BenchmarkDotNet seems to have no easy way to run using the dotnet/runtime Mono JIT, which would be useful for comparing it against CoreCLR.
This can be achieved with UseMonoRuntime
property in a csproj.
Hi @MichalPetryka
You can provide MSBuild arguments for each job. Sth like:
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
namespace BenchmarkDotNet.Samples
{
public class Program
{
public static void Main(string[] args)
{
Job net70job = Job.Default.WithRuntime(CoreRuntime.Core70);
BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args,
DefaultConfig.Instance
.AddJob(net70job.WithId("CoreCLR"))
.AddJob(net70job.WithArguments(new Argument[] { new MsBuildArgument("/p:UseMonoRuntime=true") }).WithId("Mono")));
}
}
}
I agree that it would be nice to expose UseMonoRuntime
as built-in BDN feature. We could add mono7.0
moniker and support it with --runtimes
so --runtimes net7.0 mono7.0
would compare both runtimes running as .NET 7.
@marek-safar who would be the best person to describe all UseMonoRuntime
possibilities and limitations? If this is just a matter of setting one property it should be fairly simple to implement. But we would also need to implement CLR vs Mono Runtime detection. The current one is probably outdated:
https://github.com/dotnet/BenchmarkDotNet/blob/32ddeb56bd38631e052350cecfbf9e86df1b2e7c/src/BenchmarkDotNet/Portability/RuntimeInformation.cs#L28
I would like to work on this
@Serg046 great! I've assigned you. Please let me know if you need some help
https://github.com/dotnet/runtime/blob/main/src/tests/Common/CoreCLRTestLibrary/Utilities.cs#L95 is what we use recently for MonoVM