Skip to content

Commit 8064e91

Browse files
cshungnoahfalk
andauthored
Total time in GC counter (#88699)
Co-authored-by: Noah Falk <[email protected]>
1 parent bf74880 commit 8064e91

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static class Keywords
3939
private PollingCounter? _committedCounter;
4040
private IncrementingPollingCounter? _exceptionCounter;
4141
private PollingCounter? _gcTimeCounter;
42+
private IncrementingPollingCounter? _totalGcTimeCounter;
4243
private PollingCounter? _gen0SizeCounter;
4344
private PollingCounter? _gen1SizeCounter;
4445
private PollingCounter? _gen2SizeCounter;
@@ -115,6 +116,7 @@ protected override void OnEventCommand(EventCommandEventArgs command)
115116
_committedCounter ??= new PollingCounter("gc-committed", this, () => ((double)GC.GetGCMemoryInfo().TotalCommittedBytes / 1_000_000)) { DisplayName = "GC Committed Bytes", DisplayUnits = "MB" };
116117
_exceptionCounter ??= new IncrementingPollingCounter("exception-count", this, () => Exception.GetExceptionCount()) { DisplayName = "Exception Count", DisplayRateTimeScale = new TimeSpan(0, 0, 1) };
117118
_gcTimeCounter ??= new PollingCounter("time-in-gc", this, () => GC.GetLastGCPercentTimeInGC()) { DisplayName = "% Time in GC since last GC", DisplayUnits = "%" };
119+
_totalGcTimeCounter ??= new IncrementingPollingCounter("total-time-in-gc", this, () => GC.GetTotalPauseDuration().TotalMilliseconds) { DisplayName = "Time spent in GC", DisplayUnits = "ms" };
118120
_gen0SizeCounter ??= new PollingCounter("gen-0-size", this, () => GC.GetGenerationSize(0)) { DisplayName = "Gen 0 Size", DisplayUnits = "B" };
119121
_gen1SizeCounter ??= new PollingCounter("gen-1-size", this, () => GC.GetGenerationSize(1)) { DisplayName = "Gen 1 Size", DisplayUnits = "B" };
120122
_gen2SizeCounter ??= new PollingCounter("gen-2-size", this, () => GC.GetGenerationSize(2)) { DisplayName = "Gen 2 Size", DisplayUnits = "B" };

0 commit comments

Comments
 (0)