|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 |
| -using System.Diagnostics; |
4 | 3 | using System.Linq;
|
5 | 4 | using BenchmarkDotNet.Analysers;
|
6 | 5 | using BenchmarkDotNet.Attributes;
|
|
13 | 12 | using BenchmarkDotNet.Portability;
|
14 | 13 | using BenchmarkDotNet.Reports;
|
15 | 14 | using BenchmarkDotNet.Tests.XUnit;
|
| 15 | +using BenchmarkDotNet.Toolchains; |
16 | 16 | using BenchmarkDotNet.Toolchains.InProcess.Emit;
|
17 | 17 | using Perfolizer.Horology;
|
18 | 18 | using Perfolizer.Mathematics.Thresholds;
|
@@ -123,8 +123,12 @@ private void AssertZeroResults(Type benchmarkType, IConfig config)
|
123 | 123 | bool isZero = ZeroMeasurementHelper.CheckZeroMeasurementTwoSamples(workloadMeasurements, overheadMeasurements, threshold);
|
124 | 124 | Assert.True(isZero, $"Actual time was not 0.");
|
125 | 125 |
|
126 |
| - isZero = ZeroMeasurementHelper.CheckZeroMeasurementTwoSamples(overheadMeasurements, workloadMeasurements, threshold); |
127 |
| - Assert.True(isZero, "Overhead took more time than workload."); |
| 126 | + // IL Emit has incorrect overhead measurement in net7. https://github.com/dotnet/runtime/issues/89685 |
| 127 | + if (!RuntimeInformation.IsNetCore || report.BenchmarkCase.GetToolchain() is not InProcessEmitToolchain) |
| 128 | + { |
| 129 | + isZero = ZeroMeasurementHelper.CheckZeroMeasurementTwoSamples(overheadMeasurements, workloadMeasurements, threshold); |
| 130 | + Assert.True(isZero, "Overhead took more time than workload."); |
| 131 | + } |
128 | 132 |
|
129 | 133 | Assert.True((report.GcStats.GetBytesAllocatedPerOperation(report.BenchmarkCase) ?? 0L) == 0L, "Memory allocations measured above 0.");
|
130 | 134 | }
|
@@ -163,7 +167,7 @@ public static IEnumerable<object[]> NonEmptyFrameworkData()
|
163 | 167 | }
|
164 | 168 | }
|
165 | 169 |
|
166 |
| - [Theory] |
| 170 | + [Theory(Skip = "IL Emit currently has incorrect overhead measurement, but it only matters for sub-nanosecond benchmarks like this. https://github.com/dotnet/runtime/issues/89685")] |
167 | 171 | [MemberData(nameof(NonEmptyInProcessData))]
|
168 | 172 | public void NonEmptyBenchmarksReportsNonZeroTimeAndZeroAllocated_InProcess(Type benchmarkType)
|
169 | 173 | {
|
@@ -259,11 +263,7 @@ public class ActualWork
|
259 | 263 | public int _field;
|
260 | 264 |
|
261 | 265 | [Benchmark]
|
262 |
| - public void IncrementField() |
263 |
| - { |
264 |
| - _field++; |
265 |
| - _field++; |
266 |
| - } |
| 266 | + public void IncrementField() => _field++; |
267 | 267 | }
|
268 | 268 |
|
269 | 269 | public class EmptyVoid { [Benchmark] public void Void() { } }
|
|
0 commit comments