@@ -109,9 +109,6 @@ private void AssertZeroResults(Type benchmarkType, IConfig config)
109109 . AddDiagnoser ( new MemoryDiagnoser ( new MemoryDiagnoserConfig ( false ) ) )
110110 ) ;
111111
112- var cpuResolution = RuntimeInformation . GetCpuInfo ( ) . MaxFrequency ? . ToResolution ( ) ?? FallbackCpuResolutionValue ;
113- var cpuGhz = cpuResolution . ToFrequency ( ) . ToGHz ( ) ;
114-
115112 foreach ( var report in summary . Reports )
116113 {
117114 var workloadMeasurements = report . AllMeasurements . Where ( m => m . Is ( IterationMode . Workload , IterationStage . Actual ) ) . GetStatistics ( ) . WithoutOutliers ( ) ;
@@ -120,11 +117,8 @@ private void AssertZeroResults(Type benchmarkType, IConfig config)
120117 bool isZero = ZeroMeasurementHelper . CheckZeroMeasurementTwoSamples ( workloadMeasurements , overheadMeasurements ) ;
121118 Assert . True ( isZero , $ "Actual time was not 0.") ;
122119
123- var workloadTime = workloadMeasurements . Average ( ) ;
124- var overheadTime = overheadMeasurements . Average ( ) ;
125-
126- // Allow for 1 cpu cycle variance
127- Assert . True ( overheadTime * cpuGhz < workloadTime * cpuGhz + 1 , "Overhead took more time than workload." ) ;
120+ isZero = ZeroMeasurementHelper . CheckZeroMeasurementTwoSamples ( overheadMeasurements , workloadMeasurements ) ;
121+ Assert . True ( isZero , "Overhead took more time than workload." ) ;
128122
129123 Assert . True ( ( report . GcStats . GetBytesAllocatedPerOperation ( report . BenchmarkCase ) ?? 0L ) == 0L , "Memory allocations measured above 0." ) ;
130124 }
@@ -168,9 +162,6 @@ private void AssertDifferentSizedStructsResults(IConfig config)
168162 . AddDiagnoser ( new MemoryDiagnoser ( new MemoryDiagnoserConfig ( false ) ) )
169163 ) ;
170164
171- var cpuResolution = RuntimeInformation . GetCpuInfo ( ) . MaxFrequency ? . ToResolution ( ) ?? FallbackCpuResolutionValue ;
172- var cpuGhz = cpuResolution . ToFrequency ( ) . ToGHz ( ) ;
173-
174165 foreach ( var report in summary . Reports )
175166 {
176167 var workloadMeasurements = report . AllMeasurements . Where ( m => m . Is ( IterationMode . Workload , IterationStage . Actual ) ) . GetStatistics ( ) . WithoutOutliers ( ) ;
@@ -179,11 +170,8 @@ private void AssertDifferentSizedStructsResults(IConfig config)
179170 bool isZero = ZeroMeasurementHelper . CheckZeroMeasurementTwoSamples ( workloadMeasurements , overheadMeasurements ) ;
180171 Assert . False ( isZero , $ "Actual time was 0.") ;
181172
182- var workloadTime = workloadMeasurements . Average ( ) ;
183- var overheadTime = overheadMeasurements . Average ( ) ;
184-
185- // Allow for 1 cpu cycle variance
186- Assert . True ( overheadTime * cpuGhz < workloadTime * cpuGhz + 1 , "Overhead took more time than workload." ) ;
173+ isZero = ZeroMeasurementHelper . CheckZeroMeasurementTwoSamples ( overheadMeasurements , workloadMeasurements ) ;
174+ Assert . True ( isZero , "Overhead took more time than workload." ) ;
187175
188176 Assert . True ( ( report . GcStats . GetBytesAllocatedPerOperation ( report . BenchmarkCase ) ?? 0L ) == 0L , "Memory allocations measured above 0." ) ;
189177 }
0 commit comments