BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Running with .Net 6/7 Mono JIT

Open MichalPetryka opened this issue 1 year ago • 2 comments

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.

MichalPetryka avatar Aug 02 '22 00:08 MichalPetryka

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")));
        }
    }
}

adamsitnik avatar Aug 02 '22 13:08 adamsitnik

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

adamsitnik avatar Aug 02 '22 13:08 adamsitnik

I would like to work on this

Serg046 avatar Oct 04 '22 21:10 Serg046

@Serg046 great! I've assigned you. Please let me know if you need some help

adamsitnik avatar Oct 05 '22 13:10 adamsitnik

https://github.com/dotnet/runtime/blob/main/src/tests/Common/CoreCLRTestLibrary/Utilities.cs#L95 is what we use recently for MonoVM

marek-safar avatar Oct 06 '22 15:10 marek-safar