Export (0) Print
Expand All

Performance Counters in the XNA Framework

The XNA Framework contains a set of predefined performance counters for analyzing the types of load your application has on the XNA Framework. The counters are not extensible.

You can generate performance statistics about your application at run time. See How to: Monitor Performance at Run Time (Xbox 360) for the procedure.

The performance counters are useful for understanding the impact of garbage collection and just-in-time (JIT) compilation on application performance. From these statistics, you can determine where optimizations should occur.

The statistics file lists performance counters with the following columns.

ColumnDescription
TotalSummation of occurrences
Last DatumThe last piece of information
NThe number of occurrences
MeanThe intermediate between other values
MinThe minimum value
MaxThe maximum value

XNA Framework Counters

Performance counters fall into the following categories.

Loader Counters

The following counters pertain to the portion of the common language runtime (CLR) that is responsible for resolving and loading components that are referenced by your application, such as assemblies and classes.

NameDescription
Total Program Run Time (ms)The elapsed time, in milliseconds, from CLR invocation.
App Domains CreatedThe number of application domains created in the application's process.
App Domains UnloadedThe number of application domains that have been unloaded during the run time of the application.
Assemblies LoadedThe number of assemblies that have been loaded across all application domains for the application.
Classes LoadedThe number of classes that have been loaded across all application domains during the run time of the application.
Methods LoadedThe total number of methods loaded across all application domains during the run time of the application.

Generics Counters

The generics counters are loader counters that are specific to the generics feature of the XNA Framework. The CLR uses generics internally. Consequently, you might see values in these counters even if your application does not use generics explicitly.

NameDescription
Closed Types Loaded

The count of unique generic types that have been loaded across all application domains.

A closed type is a generic class that has been bound with a specific data type. For example, an instance of MyGenericType<Int32> is a closed type.

Closed Types Loaded per Definition

The maximum number of unique generic types created for a given definition across all application domains.

For example, if an application instantiates MyGenericType<Int32>, MyGenericType<String>, and MyGenericType<Single>, the number of closed types loaded for the MyGenericType<T> definition is three (3).

A large number (several hundred or more) in the Max column can indicate working-set pressure in terms of JIT-compiled code and CLR data structures.

Open Types Loaded

The count of open generic types created across all application domains.

An open type is a generic class that has been loaded, but has not been bound with a specific data type. Open types are typically created only in reflection scenarios.

For example, loading an instance of MyGenericType<T> by using reflection will increment the Open Types Loaded counter. When the type has been bound, such as in MyGenericType<Single>, it becomes a closed type and the Closed Types Loaded counter is incremented. The XNA Framework CLR uses reflection internally and can be the source of the open types. For example, Xml serialization and Web services use reflection internally.

Closed Methods Loaded

The count of unique generic methods that have been loaded across all application domains.

A closed method is a generic method that has been bound with a specific data type. The type that contains the method may or may not be a generic type. For example, an instance of MyType.ProcessData<Int32>() is a closed method.

Closed Methods Loaded per Definition

The maximum number of unique generic methods created for a given definition across all application domains.

This counter is similar to the Closed Types Loaded per Definition counter. Using the following instances of MyType.ProcessData<Int32>(), MyType.ProcessData<String>(), and MyType.ProcessData<Single>() will create three closed methods for the MyType.ProcessData<T>() definition.

Open Methods Loaded

The count of open generic methods created across all application domains. Open methods are typically created only in reflection scenarios. An open method is a generic method that has been loaded, but is not bound to a specific type.

The XNA Framework runtime uses reflection internally and can be the source of the open methods.

Locks and Threads Counters

The following counters pertain to threading, locks, timers, and thread pools. These counters can help identify threading-related performance issues by providing data on thread, timer, and lock usage during the run time of your application.

NameDescription
Threads in Thread Pool

The number of threads currently in the thread pool.

This counter counts the threads that are started by using the System.Threading.ThreadPool.QueueUserWorkItem method. This counter does not include threads that are started by using the System.Threading.Thread.Start method.

Pending TimersThe number of timers currently queued.
Scheduled TimersThe number of timers that are currently running or scheduled to run.
Timers Delayed by Thread Pool LimitThe number of timers that have been delayed by the thread pool limit.
Work Items QueuedThe number of work items queued to the thread pool.
Uncontested Monitor.Enter CallsNumber of calls made to the System.Threading.Monitor.Enter method that were not contested.
Contested Monitor.Enter Calls

Number of calls made to Monitor.Enter that were contested.

In multi-threaded applications, if Thread1 is holding a lock and Thread2 needs to access code that is guarded by the lock, the Contested Monitor.Enter Calls counter is incremented.

Garbage Collection Counters

The following counters pertain to garbage collection operations.

NameDescription
Peak Bytes Allocated (native + managed)The maximum number of bytes in use by the CLR, including both native and managed memory.
Managed Objects AllocatedThe count of objects allocated by the garbage collector.
Unused Managed Objects AllocatedThe count of objects allocated that were never used.
Managed Bytes AllocatedThe count of bytes allocated by the garbage collector.
Unused Managed Bytes AllocatedThe count of bytes allocated that were never used.
Managed String Objects AllocatedThe number of managed string objects allocated by the garbage collector.
Bytes of String Objects AllocatedThe count of bytes of string objects allocated by the garbage collector.
Garbage Collections (GC)The number of times the garbage collector has run.
Bytes Collected by GCThe count of bytes collected by the garbage collector.
Managed Bytes in Use After GCThe number of bytes allocated to live objects after the last garbage collection.
Total Bytes in Use After GCThe number of bytes of memory, native and managed, in use after the last garbage collection.
GC CompactionsThe number of times the garbage collector has compacted the heap.
Code PitchingsThe number of times the garbage collector has discarded JIT-compiled code.
Calls to GC.CollectThe number of times the application has called the System.GC.Collect method.
GC Latency Time (ms)

The total time, in milliseconds, that the garbage collector has taken to collect objects and compact the heap.

The latency time of the garbage collector includes the time to collect managed objects that are no longer in scope and the compaction time, if necessary, of the GC Heap.

Pinned Objects

The count of pinned objects encountered while performing a garbage collection.

Pinned objects are objects whose locations in memory cannot change. For example, a memory buffer that is being used to communicate between managed and unmanaged code is a pinned object. Pinned objects cannot be moved by the garbage collector during heap compaction.

Objects Moved by CompactorThe count of objects moved by the garbage collector during a compaction.
Objects Not Moved by Compactor

The count of the objects that were not moved by the garbage collector during a compaction.

Objects might not be moved for a number of reasons. Some objects cannot be moved, but these objects are rare. Other objects are not moved because they are in a portion of the heap that does not need to be compacted.

Objects FinalizedThe count of objects for which a finalizer has been run.
Boxed Value TypesThe number of value types that have been boxed.

JIT Counters

The following counters pertain to JIT compiler operations.

NameDescription
Native Bytes Compiled JITThe count of bytes of native code generated by the JIT compiler.
Methods Compiled JITThe count of methods generated by the JIT compiler.
Bytes PitchedThe count of bytes of native code generated by the JIT compiler that has been discarded.
Methods Pitched

The count of methods generated by the JIT compiler that have been discarded.

Unless your application was moved to the background during its run time, any positive value for the Methods Pitched counter indicates that the application ran under memory pressure.

Method Pitch Latency Time (ms)The total time, in milliseconds, spent discarding methods generated by the JIT compiler.

Exceptions Counters

The following counters pertain to exceptions.

NameDescription
Exceptions Thrown

The count of managed exceptions that have been thrown.

Because throwing an exception consumes significant resources, tracking the number of exceptions thrown by your application can help identify potential design issues.

Community Additions

ADD
Show:
© 2014 Microsoft