Skip to content

Commit 197d8ed

Browse files
committed
Split TimeConsumingBenchmark class to reduce test time.
1 parent 604ff55 commit 197d8ed

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,23 @@ public void MemoryDiagnoserDoesNotIncludeAllocationsFromSetupAndCleanup(IToolcha
119119
});
120120
}
121121

122-
public class NoAllocationsAtAll
122+
public class EmptyBenchmark
123123
{
124124
[Benchmark] public void EmptyMethod() { }
125+
}
126+
127+
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
128+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
129+
public void EngineShouldNotInterfereAllocationResults(IToolchain toolchain)
130+
{
131+
AssertAllocations(toolchain, typeof(EmptyBenchmark), new Dictionary<string, long>
132+
{
133+
{ nameof(EmptyBenchmark.EmptyMethod), 0 }
134+
});
135+
}
125136

137+
public class TimeConsumingBenchmark
138+
{
126139
[Benchmark]
127140
public ulong TimeConsuming()
128141
{
@@ -135,24 +148,14 @@ public ulong TimeConsuming()
135148
}
136149
}
137150

138-
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
139-
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
140-
public void EngineShouldNotInterfereAllocationResults(IToolchain toolchain)
141-
{
142-
AssertAllocations(toolchain, typeof(NoAllocationsAtAll), new Dictionary<string, long>
143-
{
144-
{ nameof(NoAllocationsAtAll.EmptyMethod), 0 }
145-
});
146-
}
147-
148151
// #1542
149152
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
150153
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
151154
public void TieredJitShouldNotInterfereAllocationResults(IToolchain toolchain)
152155
{
153-
AssertAllocations(toolchain, typeof(NoAllocationsAtAll), new Dictionary<string, long>
156+
AssertAllocations(toolchain, typeof(TimeConsumingBenchmark), new Dictionary<string, long>
154157
{
155-
{ nameof(NoAllocationsAtAll.TimeConsuming), 0 }
158+
{ nameof(TimeConsumingBenchmark.TimeConsuming), 0 }
156159
},
157160
disableTieredJit: false, iterationCount: 10); // 1 iteration is not enough to repro the problem
158161
}

0 commit comments

Comments
 (0)