-
-
Notifications
You must be signed in to change notification settings - Fork 987
/
Copy pathMultipleRuntimesTest.cs
67 lines (58 loc) · 2.44 KB
/
MultipleRuntimesTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.IntegrationTests.Xunit;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Tests.Loggers;
using BenchmarkDotNet.Tests.XUnit;
using BenchmarkDotNet.Toolchains;
using Xunit;
using Xunit.Abstractions;
namespace BenchmarkDotNet.IntegrationTests
{
public class MultipleRuntimesTest
{
private readonly ITestOutputHelper output;
public MultipleRuntimesTest(ITestOutputHelper outputHelper) => output = outputHelper;
[FactEnvSpecific("CLR is a valid job only on Windows", EnvRequirement.WindowsOnly)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void SingleBenchmarkCanBeExecutedForMultipleRuntimes()
{
var summary = BenchmarkRunner
.Run<C>(
ManualConfig.CreateEmpty()
.AddJob(Job.Dry.WithRuntime(CoreRuntime.Core80).WithPlatform(Platform.X64).WithId("Core"))
.AddJob(Job.Dry.WithRuntime(ClrRuntime.Net462).WithId("Framework"))
.AddColumnProvider(DefaultColumnProviders.Instance)
.AddLogger(new OutputLogger(output)));
Assert.True(summary.Reports
.All(report => report.ExecuteResults
.All(executeResult => executeResult.FoundExecutable)));
Assert.True(summary.Reports.All(report => report.AllMeasurements.Any()));
Assert.True(summary.Reports
.Single(report => report.BenchmarkCase.Job.Environment.Runtime is ClrRuntime)
.ExecuteResults
.Any());
Assert.True(summary.Reports
.Single(report => report.BenchmarkCase.Job.Environment.Runtime is CoreRuntime)
.ExecuteResults
.Any());
Assert.Contains(".NET Framework", summary.AllRuntimes);
Assert.Contains(".NET 8.0", summary.AllRuntimes);
}
}
// this test was suffering from too long path ex so I had to rename the class and benchmark method to fit within the limit
public class C
{
[Benchmark]
public void B()
{
Console.WriteLine($"// {RuntimeInformation.GetCurrentRuntime().GetToolchain()}");
}
}
}