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(
82
82
pilotStage = new EnginePilotStage ( this ) ;
83
83
actualStage = new EngineActualStage ( this ) ;
84
84
85
+ // Necessary for CORE runtimes.
85
86
if ( includeSurvivedMemory )
86
87
{
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.
88
91
MeasureAction ( _ => { } , 0 ) ;
92
+ GcStats . StopMeasuringSurvived ( includeSurvivedMemory ) ;
93
+ // Clear total measured to not pollute actual measurement.
94
+ GcStats . ClearTotalMeasuredSurvived ( ) ;
89
95
}
90
96
}
91
97
Original file line number Diff line number Diff line change @@ -269,6 +269,11 @@ public static long StopMeasuringSurvived(bool measure)
269
269
return measured ;
270
270
}
271
271
272
+ public static void ClearTotalMeasuredSurvived ( )
273
+ {
274
+ _totalMeasured = 0 ;
275
+ }
276
+
272
277
private static long GetTotalBytes ( bool actual )
273
278
{
274
279
if ( ! actual || RuntimeInformation . IsMono ) // Monitoring is not available in Mono.
You can’t perform that action at this time.
0 commit comments