-
Notifications
You must be signed in to change notification settings - Fork 6
/
Program.cs
40 lines (31 loc) · 1.04 KB
/
Program.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
// Made by Benjamin Abt - https://github.com/BenjaminAbt
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<Benchmark>();
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net70)] // PGO enabled by default
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[HideColumns(Column.Job)]
public class Benchmark
{
[Benchmark]
public MyClass Class()
=> new("Batman");
[Benchmark]
public IName ClassWithInterface()
=> new MyClassWithInterface("Batman");
[Benchmark]
public MyStruct Struct()
=> new("Batman");
[Benchmark]
public IName StructWithInterface()
=> new MyStructWithInterface("Batman");
}
public readonly record struct MyStruct(string Name);
public readonly record struct MyStructWithInterface(string Name) : IName;
public record class MyClass(string Name);
public record class MyClassWithInterface(string Name) : IName;
public interface IName { string Name { get; } }