-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathStackWalk.cs
81 lines (76 loc) · 3.48 KB
/
StackWalk.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
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using MicroBenchmarks;
namespace PerfLabTests
{
[BenchmarkCategory(Categories.Runtime, Categories.Perflab)]
public class StackWalk
{
public static int InnerIterationCount = 1000; // do not change the value and keep it public static NOT-readonly, ported "as is" from CoreCLR repo
[Benchmark]
public void Walk()
{
A(5);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static int A(int a) { return B(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int B(int a) { return C(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int C(int a) { return D(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int D(int a) { return E(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int E(int a) { return F(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int F(int a) { return G(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int G(int a) { return H(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int H(int a) { return I(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int I(int a) { return J(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int J(int a) { return K(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int K(int a) { return L(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int L(int a) { return M(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int M(int a) { return N(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int N(int a) { return O(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int O(int a) { return P(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int P(int a) { return Q(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int Q(int a) { return R(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int R(int a) { return S(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int S(int a) { return T(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int T(int a) { return U(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int U(int a) { return V(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int V(int a) { return W(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int W(int a) { return X(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int X(int a) { return Y(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int Y(int a) { return Z(a + 5); }
[MethodImpl(MethodImplOptions.NoInlining)]
private static int Z(int a)
{
for (int i = 0; i < InnerIterationCount; i++)
GC.Collect(0);
return 55;
}
}
}