internal static Runtime GetCurrentRuntime()
        {
            //do not change the order of conditions because it may cause incorrect determination of runtime
            if (IsMono)
            {
                return(MonoRuntime.Default);
            }
            if (IsFullFramework)
            {
                return(ClrRuntime.GetCurrentVersion());
            }
            if (IsWasm)
            {
                return(WasmRuntime.Default);
            }
            if (IsNetCore)
            {
                return(CoreRuntime.GetCurrentVersion());
            }
            if (IsCoreRT)
            {
                return(CoreRtRuntime.GetCurrentVersion());
            }

            throw new NotSupportedException("Unknown .NET Runtime");
        }
        public void CustomClrBuildJobsAreGroupedByVersion()
        {
            const string version = "abcd";

            var config = ManualConfig.Create(DefaultConfig.Instance)
                         .With(Job.Default.With(ClrRuntime.CreateForLocalFullNetFrameworkBuild(version: version)))
                         .With(Job.Default.With(ClrRuntime.CreateForLocalFullNetFrameworkBuild(version: "it's a different version")))
                         .With(Job.Default.With(ClrRuntime.GetCurrentVersion()));

            var benchmarks1 = BenchmarkConverter.TypeToBenchmarks(typeof(Plain1), config);
            var benchmarks2 = BenchmarkConverter.TypeToBenchmarks(typeof(Plain2), config);

            var grouped = benchmarks1.BenchmarksCases.Union(benchmarks2.BenchmarksCases)
                          .GroupBy(benchmark => benchmark, new BenchmarkPartitioner.BenchmarkRuntimePropertiesComparer())
                          .ToArray();

            Assert.Equal(3, grouped.Length); // Job.Clr + Job.Clr(version) + Job.Clr(different)

            foreach (var grouping in grouped)
            {
                Assert.Equal(3 * 2, grouping.Count()); // (M1 + M2 + M3) * (Plain1 + Plain2)
            }
        }
Example #3
0
 public ClrJobAttribute() : base(Job.Default.With(ClrRuntime.GetCurrentVersion()))
 {
 }
Example #4
0
 public DryClrJobAttribute() : base(Job.Dry.With(ClrRuntime.GetCurrentVersion()))
 {
 }