File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/BenchmarkDotNet/Engines Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,16 @@ internal Engine(
8282 pilotStage = new EnginePilotStage ( this ) ;
8383 actualStage = new EngineActualStage ( this ) ;
8484
85+ // Necessary for CORE runtimes.
8586 if ( includeSurvivedMemory )
8687 {
87- // Run the clock once to set static memory (necessary for CORE runtimes).
88+ // Measure survived once to allow jit to make its allocations.
89+ GcStats . StartMeasuringSurvived ( includeSurvivedMemory ) ;
90+ // Run the clock once to set static memory.
8891 MeasureAction ( _ => { } , 0 ) ;
92+ GcStats . StopMeasuringSurvived ( includeSurvivedMemory ) ;
93+ // Clear total measured to not pollute actual measurement.
94+ GcStats . ClearTotalMeasuredSurvived ( ) ;
8995 }
9096 }
9197
Original file line number Diff line number Diff line change @@ -269,6 +269,11 @@ public static long StopMeasuringSurvived(bool measure)
269269 return measured ;
270270 }
271271
272+ public static void ClearTotalMeasuredSurvived ( )
273+ {
274+ _totalMeasured = 0 ;
275+ }
276+
272277 private static long GetTotalBytes ( bool actual )
273278 {
274279 if ( ! actual || RuntimeInformation . IsMono ) // Monitoring is not available in Mono.
You can’t perform that action at this time.
0 commit comments