Skip to content

Commit 475ab45

Browse files
Move Smoke benchmarks to BenchmarkDotNet.Samples
IntroSmokeIncrements was taken from #2334 (comment)
1 parent 92f33f2 commit 475ab45

File tree

5 files changed

+290
-159
lines changed

5 files changed

+290
-159
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using BenchmarkDotNet.Attributes;
2+
3+
namespace BenchmarkDotNet.Samples;
4+
5+
[DisassemblyDiagnoser]
6+
public class IntroSmokeEmptyBasic
7+
{
8+
[Benchmark] public void Void1() {}
9+
[Benchmark] public void Void2() {}
10+
[Benchmark] public void Void3() {}
11+
[Benchmark] public void Void4() {}
12+
13+
[Benchmark] public byte Byte1() => 0;
14+
[Benchmark] public byte Byte2() => 0;
15+
[Benchmark] public byte Byte3() => 0;
16+
[Benchmark] public byte Byte4() => 0;
17+
18+
[Benchmark] public sbyte Sbyte1() => 0;
19+
[Benchmark] public sbyte Sbyte2() => 0;
20+
[Benchmark] public sbyte Sbyte3() => 0;
21+
[Benchmark] public sbyte Sbyte4() => 0;
22+
23+
[Benchmark] public short Short1() => 0;
24+
[Benchmark] public short Short2() => 0;
25+
[Benchmark] public short Short3() => 0;
26+
[Benchmark] public short Short4() => 0;
27+
28+
[Benchmark] public ushort Ushort1() => 0;
29+
[Benchmark] public ushort Ushort2() => 0;
30+
[Benchmark] public ushort Ushort3() => 0;
31+
[Benchmark] public ushort Ushort4() => 0;
32+
33+
[Benchmark] public int Int1() => 0;
34+
[Benchmark] public int Int2() => 0;
35+
[Benchmark] public int Int3() => 0;
36+
[Benchmark] public int Int4() => 0;
37+
38+
[Benchmark] public uint Uint1() => 0u;
39+
[Benchmark] public uint Uint2() => 0u;
40+
[Benchmark] public uint Uint3() => 0u;
41+
[Benchmark] public uint Uint4() => 0u;
42+
43+
[Benchmark] public bool Bool1() => false;
44+
[Benchmark] public bool Bool2() => false;
45+
[Benchmark] public bool Bool3() => false;
46+
[Benchmark] public bool Bool4() => false;
47+
48+
[Benchmark] public char Char1() => 'a';
49+
[Benchmark] public char Char2() => 'a';
50+
[Benchmark] public char Char3() => 'a';
51+
[Benchmark] public char Char4() => 'a';
52+
53+
[Benchmark] public float Float1() => 0f;
54+
[Benchmark] public float Float2() => 0f;
55+
[Benchmark] public float Float3() => 0f;
56+
[Benchmark] public float Float4() => 0f;
57+
58+
[Benchmark] public double Double1() => 0d;
59+
[Benchmark] public double Double2() => 0d;
60+
[Benchmark] public double Double3() => 0d;
61+
[Benchmark] public double Double4() => 0d;
62+
63+
[Benchmark] public long Long1() => 0L;
64+
[Benchmark] public long Long2() => 0L;
65+
[Benchmark] public long Long3() => 0L;
66+
[Benchmark] public long Long4() => 0L;
67+
68+
[Benchmark] public ulong Ulong1() => 0uL;
69+
[Benchmark] public ulong Ulong2() => 0uL;
70+
[Benchmark] public ulong Ulong3() => 0uL;
71+
[Benchmark] public ulong Ulong4() => 0uL;
72+
73+
[Benchmark] public string String1() => "";
74+
[Benchmark] public string String2() => "";
75+
[Benchmark] public string String3() => "";
76+
[Benchmark] public string String4() => "";
77+
78+
[Benchmark] public object? Object1() => null;
79+
[Benchmark] public object? Object2() => null;
80+
[Benchmark] public object? Object3() => null;
81+
[Benchmark] public object? Object4() => null;
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using BenchmarkDotNet.Attributes;
2+
3+
namespace BenchmarkDotNet.Samples;
4+
5+
public class IntroSmokeIncrements
6+
{
7+
public int Field;
8+
9+
[Benchmark]
10+
public void Increment01()
11+
{
12+
Field++;
13+
}
14+
15+
[Benchmark]
16+
public void Increment02()
17+
{
18+
Field++;
19+
Field++;
20+
}
21+
22+
[Benchmark]
23+
public void Increment03()
24+
{
25+
Field++;
26+
Field++;
27+
Field++;
28+
}
29+
30+
[Benchmark]
31+
public void Increment04()
32+
{
33+
Field++;
34+
Field++;
35+
Field++;
36+
Field++;
37+
}
38+
39+
[Benchmark]
40+
public void Increment05()
41+
{
42+
Field++;
43+
Field++;
44+
Field++;
45+
Field++;
46+
Field++;
47+
}
48+
49+
[Benchmark]
50+
public void Increment06()
51+
{
52+
Field++;
53+
Field++;
54+
Field++;
55+
Field++;
56+
Field++;
57+
Field++;
58+
}
59+
60+
[Benchmark]
61+
public void Increment07()
62+
{
63+
Field++;
64+
Field++;
65+
Field++;
66+
Field++;
67+
Field++;
68+
Field++;
69+
Field++;
70+
}
71+
72+
[Benchmark]
73+
public void Increment08()
74+
{
75+
Field++;
76+
Field++;
77+
Field++;
78+
Field++;
79+
Field++;
80+
Field++;
81+
Field++;
82+
Field++;
83+
}
84+
85+
[Benchmark]
86+
public void Increment09()
87+
{
88+
Field++;
89+
Field++;
90+
Field++;
91+
Field++;
92+
Field++;
93+
Field++;
94+
Field++;
95+
Field++;
96+
Field++;
97+
}
98+
99+
[Benchmark]
100+
public void Increment10()
101+
{
102+
Field++;
103+
Field++;
104+
Field++;
105+
Field++;
106+
Field++;
107+
Field++;
108+
Field++;
109+
Field++;
110+
Field++;
111+
Field++;
112+
}
113+
114+
[Benchmark]
115+
public void Increment20()
116+
{
117+
Field++;
118+
Field++;
119+
Field++;
120+
Field++;
121+
Field++;
122+
Field++;
123+
Field++;
124+
Field++;
125+
Field++;
126+
Field++;
127+
Field++;
128+
Field++;
129+
Field++;
130+
Field++;
131+
Field++;
132+
Field++;
133+
Field++;
134+
Field++;
135+
Field++;
136+
Field++;
137+
}
138+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using BenchmarkDotNet.Attributes;
4+
using BenchmarkDotNet.Environments;
5+
6+
namespace BenchmarkDotNet.Samples;
7+
8+
[MemoryDiagnoser, DisassemblyDiagnoser]
9+
public class IntroSmokeValueTypes
10+
{
11+
[Benchmark] public Jit ReturnEnum() => Jit.RyuJit;
12+
13+
[Benchmark] public DateTime ReturnDateTime() => new DateTime();
14+
15+
[Benchmark] public DateTime? ReturnNullableDateTime() => new DateTime();
16+
[Benchmark] public int? ReturnNullableInt() => 0;
17+
18+
public struct StructWithReferencesOnly { public object _ref; }
19+
[Benchmark] public StructWithReferencesOnly ReturnStructWithReferencesOnly() => new StructWithReferencesOnly();
20+
21+
public struct EmptyStruct { }
22+
[Benchmark] public EmptyStruct ReturnEmptyStruct() => new EmptyStruct();
23+
24+
[Benchmark] public ValueTuple<int> ReturnGenericStructOfValueType() => new ValueTuple<int>(0);
25+
[Benchmark] public ValueTuple<object> ReturnGenericStructOfReferenceType() => new ValueTuple<object>(null);
26+
27+
[Benchmark] public ValueTask<int> ReturnValueTaskOfValueType() => new ValueTask<int>(0);
28+
[Benchmark] public ValueTask<object> ReturnValueTaskOfReferenceType() => new ValueTask<object>(result: null);
29+
30+
[Benchmark] public byte ReturnByte() => 0;
31+
public struct Byte1 { public byte _1; }
32+
[Benchmark] public Byte1 ReturnByte1() => new Byte1();
33+
public struct Byte2 { public byte _1, _2; }
34+
[Benchmark] public Byte2 ReturnByte2() => new Byte2();
35+
public struct Byte3 { public byte _1, _2, _3; }
36+
[Benchmark] public Byte3 ReturnByte3() => new Byte3();
37+
public struct Byte4 { public byte _1, _2, _3, _4; }
38+
[Benchmark] public Byte4 ReturnByte4() => new Byte4();
39+
40+
[Benchmark] public short ReturnShort() => 0;
41+
public struct Short1 { public short _1; }
42+
[Benchmark] public Short1 ReturnShort1() => new Short1();
43+
public struct Short2 { public short _1, _2; }
44+
[Benchmark] public Short2 ReturnShort2() => new Short2();
45+
public struct Short3 { public short _1, _2, _3; }
46+
[Benchmark] public Short3 ReturnShort3() => new Short3();
47+
public struct Short4 { public short _1, _2, _3, _4; }
48+
[Benchmark] public Short4 ReturnShort4() => new Short4();
49+
50+
[Benchmark] public int ReturnInt() => 0;
51+
public struct Int1 { public int _1; }
52+
[Benchmark] public Int1 ReturnInt1() => new Int1();
53+
public struct Int2 { public int _1, _2; }
54+
[Benchmark] public Int2 ReturnInt2() => new Int2();
55+
public struct Int3 { public int _1, _2, _3; }
56+
[Benchmark] public Int3 ReturnInt3() => new Int3();
57+
public struct Int4 { public int _1, _2, _3, _4; }
58+
[Benchmark] public Int4 ReturnInt4() => new Int4();
59+
60+
[Benchmark] public long ReturnLong() => 0;
61+
public struct Long1 { public long _1; }
62+
[Benchmark] public Long1 ReturnLong1() => new Long1();
63+
public struct Long2 { public long _1, _2; }
64+
[Benchmark] public Long2 ReturnLong2() => new Long2();
65+
public struct Long3 { public long _1, _2, _3; }
66+
[Benchmark] public Long3 ReturnLong3() => new Long3();
67+
public struct Long4 { public long _1, _2, _3, _4; }
68+
[Benchmark] public Long4 ReturnLong4() => new Long4();
69+
}
70+
// ReSharper restore InconsistentNaming

tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Smoke/SmokeEmpty.cs

-85
This file was deleted.

0 commit comments

Comments
 (0)