-
-
Notifications
You must be signed in to change notification settings - Fork 978
/
IntroCustomMono.cs
95 lines (83 loc) · 2.59 KB
/
IntroCustomMono.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
namespace BenchmarkDotNet.Samples
{
// *** Attribute Style ***
[MonoJob("Mono x64", @"C:\Program Files\Mono\bin\mono.exe")]
[MonoJob("Mono x86", @"C:\Program Files (x86)\Mono\bin\mono.exe")]
public class IntroCustomMono
{
[Benchmark]
public void Foo()
{
// Benchmark body
}
}
// *** Object Style ***
[Config(typeof(Config))]
public class IntroCustomMonoObjectStyle
{
private class Config : ManualConfig
{
public Config()
{
AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(
"Mono x64", @"C:\Program Files\Mono\bin\mono.exe")));
AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(
"Mono x86", @"C:\Program Files (x86)\Mono\bin\mono.exe")));
}
}
[Benchmark]
public void Foo()
{
// Benchmark body
}
}
// ** Object Style, Using AOT **
[Config(typeof(Config))]
public class IntroCustomMonoObjectStyleAot
{
private class Config : ManualConfig
{
public void AddMono (string name, string mono_top_dir)
{
var aot_compile_args = "--aot=llvm";
var mono_bcl = $@"{mono_top_dir}\lib\mono\4.5";
var mono_bin = $@"{mono_top_dir}\bin\mono.exe";
AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(
name, mono_bin, aot_compile_args, mono_bcl)));
}
public Config()
{
AddMono("Mono x64", @"C:\Program Files\Mono");
AddMono("Mono x86", @"C:\Program Files (x86)\Mono");
}
}
[Benchmark]
public void Foo()
{
// Benchmark body
}
}
// *** Fluent Config ***
public class IntroCustomMonoFluentConfig
{
public static void Run()
{
BenchmarkRunner.Run<IntroCustomMonoFluentConfig>(ManualConfig
.CreateMinimumViable()
.AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(
"Mono x64", @"C:\Program Files\Mono\bin\mono.exe")))
.AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(
"Mono x86", @"C:\Program Files (x86)\Mono\bin\mono.exe"))));
}
[Benchmark]
public void Foo()
{
// Benchmark body
}
}
}