Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ OnEventCommand()

override void System.Diagnostics.Tracing.RuntimeEventSource.OnEventCommand ( EventCommandEventArgs command)
inlineprotectedvirtual

Reimplemented from System.Diagnostics.Tracing.EventSource.

Definition at line 95 of file RuntimeEventSource.cs.

96 {
97 if (command.Command != EventCommand.Enable)
98 {
99 return;
100 }
101 if (_cpuTimeCounter == null)
102 {
103 _cpuTimeCounter = new PollingCounter("cpu-usage", this, () => RuntimeEventSourceHelper.GetCpuUsage())
104 {
105 DisplayName = "CPU Usage",
106 DisplayUnits = "%"
107 };
108 }
109 if (_workingSetCounter == null)
110 {
111 _workingSetCounter = new PollingCounter("working-set", this, () => Environment.WorkingSet / 1000000)
112 {
113 DisplayName = "Working Set",
114 DisplayUnits = "MB"
115 };
116 }
117 if (_gcHeapSizeCounter == null)
118 {
119 _gcHeapSizeCounter = new PollingCounter("gc-heap-size", this, () => GC.GetTotalMemory(forceFullCollection: false) / 1000000)
120 {
121 DisplayName = "GC Heap Size",
122 DisplayUnits = "MB"
123 };
124 }
125 if (_gen0GCCounter == null)
126 {
127 _gen0GCCounter = new IncrementingPollingCounter("gen-0-gc-count", this, () => GC.CollectionCount(0))
128 {
129 DisplayName = "Gen 0 GC Count",
130 DisplayRateTimeScale = new TimeSpan(0, 1, 0)
131 };
132 }
133 if (_gen1GCCounter == null)
134 {
135 _gen1GCCounter = new IncrementingPollingCounter("gen-1-gc-count", this, () => GC.CollectionCount(1))
136 {
137 DisplayName = "Gen 1 GC Count",
138 DisplayRateTimeScale = new TimeSpan(0, 1, 0)
139 };
140 }
141 if (_gen2GCCounter == null)
142 {
143 _gen2GCCounter = new IncrementingPollingCounter("gen-2-gc-count", this, () => GC.CollectionCount(2))
144 {
145 DisplayName = "Gen 2 GC Count",
146 DisplayRateTimeScale = new TimeSpan(0, 1, 0)
147 };
148 }
149 if (_threadPoolThreadCounter == null)
150 {
151 _threadPoolThreadCounter = new PollingCounter("threadpool-thread-count", this, () => ThreadPool.ThreadCount)
152 {
153 DisplayName = "ThreadPool Thread Count"
154 };
155 }
156 if (_monitorContentionCounter == null)
157 {
158 _monitorContentionCounter = new IncrementingPollingCounter("monitor-lock-contention-count", this, () => Monitor.LockContentionCount)
159 {
160 DisplayName = "Monitor Lock Contention Count",
161 DisplayRateTimeScale = new TimeSpan(0, 0, 1)
162 };
163 }
164 if (_threadPoolQueueCounter == null)
165 {
166 _threadPoolQueueCounter = new PollingCounter("threadpool-queue-length", this, () => ThreadPool.PendingWorkItemCount)
167 {
168 DisplayName = "ThreadPool Queue Length"
169 };
170 }
171 if (_completedItemsCounter == null)
172 {
173 _completedItemsCounter = new IncrementingPollingCounter("threadpool-completed-items-count", this, () => ThreadPool.CompletedWorkItemCount)
174 {
175 DisplayName = "ThreadPool Completed Work Item Count",
176 DisplayRateTimeScale = new TimeSpan(0, 0, 1)
177 };
178 }
179 if (_allocRateCounter == null)
180 {
181 _allocRateCounter = new IncrementingPollingCounter("alloc-rate", this, () => GC.GetTotalAllocatedBytes())
182 {
183 DisplayName = "Allocation Rate",
184 DisplayUnits = "B",
185 DisplayRateTimeScale = new TimeSpan(0, 0, 1)
186 };
187 }
188 if (_timerCounter == null)
189 {
190 _timerCounter = new PollingCounter("active-timer-count", this, () => Timer.ActiveCount)
191 {
192 DisplayName = "Number of Active Timers"
193 };
194 }
195 if (_fragmentationCounter == null)
196 {
197 _fragmentationCounter = new PollingCounter("gc-fragmentation", this, delegate
198 {
199 GCMemoryInfo gCMemoryInfo = GC.GetGCMemoryInfo();
200 return (gCMemoryInfo.HeapSizeBytes == 0L) ? 0.0 : ((double)gCMemoryInfo.FragmentedBytes * 100.0 / (double)gCMemoryInfo.HeapSizeBytes);
201 })
202 {
203 DisplayName = "GC Fragmentation",
204 DisplayUnits = "%"
205 };
206 }
207 if (_committedCounter == null)
208 {
209 _committedCounter = new PollingCounter("gc-committed", this, () => GC.GetGCMemoryInfo().TotalCommittedBytes / 1000000)
210 {
211 DisplayName = "GC Committed Bytes",
212 DisplayUnits = "MB"
213 };
214 }
215 if (_exceptionCounter == null)
216 {
217 _exceptionCounter = new IncrementingPollingCounter("exception-count", this, () => Exception.GetExceptionCount())
218 {
219 DisplayName = "Exception Count",
220 DisplayRateTimeScale = new TimeSpan(0, 0, 1)
221 };
222 }
223 if (_gcTimeCounter == null)
224 {
225 _gcTimeCounter = new PollingCounter("time-in-gc", this, () => GC.GetLastGCPercentTimeInGC())
226 {
227 DisplayName = "% Time in GC since last GC",
228 DisplayUnits = "%"
229 };
230 }
231 if (_gen0SizeCounter == null)
232 {
233 _gen0SizeCounter = new PollingCounter("gen-0-size", this, () => GC.GetGenerationSize(0))
234 {
235 DisplayName = "Gen 0 Size",
236 DisplayUnits = "B"
237 };
238 }
239 if (_gen1SizeCounter == null)
240 {
241 _gen1SizeCounter = new PollingCounter("gen-1-size", this, () => GC.GetGenerationSize(1))
242 {
243 DisplayName = "Gen 1 Size",
244 DisplayUnits = "B"
245 };
246 }
247 if (_gen2SizeCounter == null)
248 {
249 _gen2SizeCounter = new PollingCounter("gen-2-size", this, () => GC.GetGenerationSize(2))
250 {
251 DisplayName = "Gen 2 Size",
252 DisplayUnits = "B"
253 };
254 }
255 if (_lohSizeCounter == null)
256 {
257 _lohSizeCounter = new PollingCounter("loh-size", this, () => GC.GetGenerationSize(3))
258 {
259 DisplayName = "LOH Size",
260 DisplayUnits = "B"
261 };
262 }
263 if (_pohSizeCounter == null)
264 {
265 _pohSizeCounter = new PollingCounter("poh-size", this, () => GC.GetGenerationSize(4))
266 {
267 DisplayName = "POH (Pinned Object Heap) Size",
268 DisplayUnits = "B"
269 };
270 }
271 if (_assemblyCounter == null)
272 {
273 _assemblyCounter = new PollingCounter("assembly-count", this, () => Assembly.GetAssemblyCount())
274 {
275 DisplayName = "Number of Assemblies Loaded"
276 };
277 }
278 if (_ilBytesJittedCounter == null)
279 {
280 _ilBytesJittedCounter = new PollingCounter("il-bytes-jitted", this, () => JitInfo.GetCompiledILBytes())
281 {
282 DisplayName = "IL Bytes Jitted",
283 DisplayUnits = "B"
284 };
285 }
286 if (_methodsJittedCounter == null)
287 {
288 _methodsJittedCounter = new PollingCounter("methods-jitted-count", this, () => JitInfo.GetCompiledMethodCount())
289 {
290 DisplayName = "Number of Methods Jitted"
291 };
292 }
293 if (_jitTimeCounter == null)
294 {
295 _jitTimeCounter = new IncrementingPollingCounter("time-in-jit", this, () => JitInfo.GetCompilationTime().TotalMilliseconds)
296 {
297 DisplayName = "Time spent in JIT",
298 DisplayUnits = "ms",
299 DisplayRateTimeScale = new TimeSpan(0, 0, 1)
300 };
301 }
302 AppContext.LogSwitchValues(this);
303 }
static uint GetAssemblyCount()
static long GetCompiledILBytes(bool currentThread=false)
static long GetCompiledMethodCount(bool currentThread=false)
static TimeSpan GetCompilationTime(bool currentThread=false)
Definition JitInfo.cs:16
static long LockContentionCount
Definition Monitor.cs:10
static long PendingWorkItemCount
Definition ThreadPool.cs:72
static long CompletedWorkItemCount
Definition ThreadPool.cs:35
static long ActiveCount
Definition Timer.cs:15

References System.Diagnostics.Tracing.RuntimeEventSource._allocRateCounter, System.Diagnostics.Tracing.RuntimeEventSource._assemblyCounter, System.Diagnostics.Tracing.RuntimeEventSource._committedCounter, System.Diagnostics.Tracing.RuntimeEventSource._completedItemsCounter, System.Diagnostics.Tracing.RuntimeEventSource._cpuTimeCounter, System.Diagnostics.Tracing.RuntimeEventSource._exceptionCounter, System.Diagnostics.Tracing.RuntimeEventSource._fragmentationCounter, System.Diagnostics.Tracing.RuntimeEventSource._gcHeapSizeCounter, System.Diagnostics.Tracing.RuntimeEventSource._gcTimeCounter, System.Diagnostics.Tracing.RuntimeEventSource._gen0GCCounter, System.Diagnostics.Tracing.RuntimeEventSource._gen0SizeCounter, System.Diagnostics.Tracing.RuntimeEventSource._gen1GCCounter, System.Diagnostics.Tracing.RuntimeEventSource._gen1SizeCounter, System.Diagnostics.Tracing.RuntimeEventSource._gen2GCCounter, System.Diagnostics.Tracing.RuntimeEventSource._gen2SizeCounter, System.Diagnostics.Tracing.RuntimeEventSource._ilBytesJittedCounter, System.Diagnostics.Tracing.RuntimeEventSource._jitTimeCounter, System.Diagnostics.Tracing.RuntimeEventSource._lohSizeCounter, System.Diagnostics.Tracing.RuntimeEventSource._methodsJittedCounter, System.Diagnostics.Tracing.RuntimeEventSource._monitorContentionCounter, System.Diagnostics.Tracing.RuntimeEventSource._pohSizeCounter, System.Diagnostics.Tracing.RuntimeEventSource._threadPoolQueueCounter, System.Diagnostics.Tracing.RuntimeEventSource._threadPoolThreadCounter, System.Diagnostics.Tracing.RuntimeEventSource._timerCounter, System.Diagnostics.Tracing.RuntimeEventSource._workingSetCounter, System.Threading.Timer.ActiveCount, System.GC.CollectionCount(), System.Diagnostics.Tracing.EventCommandEventArgs.Command, System.Threading.ThreadPool.CompletedWorkItemCount, System.GCMemoryInfo.FragmentedBytes, System.Reflection.Assembly.GetAssemblyCount(), System.Runtime.JitInfo.GetCompilationTime(), System.Runtime.JitInfo.GetCompiledILBytes(), System.Runtime.JitInfo.GetCompiledMethodCount(), System.Diagnostics.Tracing.RuntimeEventSourceHelper.GetCpuUsage(), System.Exception.GetExceptionCount(), System.GC.GetGCMemoryInfo(), System.GC.GetGenerationSize(), System.GC.GetLastGCPercentTimeInGC(), System.GC.GetTotalAllocatedBytes(), System.GC.GetTotalMemory(), System.GCMemoryInfo.HeapSizeBytes, System.L, System.Threading.Monitor.LockContentionCount, System.AppContext.LogSwitchValues(), System.Threading.ThreadPool.PendingWorkItemCount, System.Threading.ThreadPool.ThreadCount, and System.Environment.WorkingSet.