Game Development Reference
In-Depth Information
CLR Profiler and GC Monitoring
Proper measurement metrics are a necessity when performance tuning an appli-
cation, so you will need quantifiable methods to determine your allocation profile.
Two such methods are described in this section: performance counters and the
CLR Profiler.
Performance Counters
The Microsoft runtime team created a variety of performance counters to evaluate
a few core .NET components, including the garbage collector, which can be used
to study the garbage collector in a multitude of ways.
The first thing to do is launch the Performance Counter utility, which you can do
by typing perfmon.exe into the Run dialog from the Start Menu or directly at the
command prompt. Once the utility launches, you need to add the appropriate per-
formance counter(s) by pressing Ctrl+I, or by clicking on the plus sign button like
the one shown in Figure 34.1.
Figure 34.1
The button to add counters to the performance monitor utility.
The performance counters applicable to the garbage collector reside in the .NET
CLR Memory performance object. Perhaps the most important counter metric in
this performance object is the total processor time that is spent on garbage collec-
tion, known as the % Time in GC performance counter. Launch the managed appli-
cation that you wish to profile and select it from the instance list for the % Time in
GC counter. You should be presented with a dialog similar to the one shown in
Figure 34.2.
After selecting the performance counters that you wish to analyze, you will imme-
diately begin seeing the graph display data for the metrics you have selected. You
can now test functionality in your application and witness the level of exertion by
the GC in managing your memory. Figure 34.3 shows the performance monitor
utility displaying the % Time in GC performance counter for the World Builder appli-
Search Nedrilad ::

Custom Search