This is the third part in the series describing .NET Compact Framework v2 performance counters. A complete listing of this series, to date, is included below.
Monitoring Application Performance on the .NET Compact Framework Part I - Enabling performance counters
.NET Compact Framework Version 1:
Monitoring Application Performance on the .NET Compact Framework Part II - Version 1 performance counters
.NET Compact Framework Version 2:
Monitoring Application Performance on the .NET Compact Framework Part III - Version 2 performance counters (Part I: Loader counters)
Monitoring Application Performance on the .NET Compact Framework Part IV - Version 2 performance counters (Part II: Generics counters)
The following table lists all of the performance counters available in version 2 of the .NET Compact Framework. The counters highlighted, in yellow, are the ones I will be talking about today.
|Total Program Run Time (ms)|
|App Domains Created|
|App Domains Unloaded|
|Closed Types Loaded|
|Closed Types Loaded per Definition|
|Open Types Loaded|
|Closed Methods Loaded|
|Closed Methods Loaded per Definition|
|Open Methods Loaded|
|Locks and Threads|
|Threads in Thread Pool|
|Timers Delayed by Thread Pool Limit|
|Work Items Queued|
|Uncontested Monitor.Enter Calls|
|Contested Monitor.Enter Calls|
|Peak Bytes Allocated (native + managed)|
|Managed Objects Allocated|
|Managed Bytes Allocated|
|Managed String Objects Allocated|
|Bytes of String Objects Allocated|
|Garbage Collections (GC)|
|Bytes Collected By GC|
|Managed Bytes In Use After GC|
|Total Bytes In Use After GC|
|Calls to GC.Collect|
|GC Latency Time (ms)|
|Objects Moved by Compactor|
|Objects Not Moved by Compactor|
|Boxed Value Types|
|Short Term Heap|
|App Domain Heap|
|Native Bytes Jitted|
|Method Pitch Latency Time (ms)|
|Platform Invoke Calls|
|COM Calls Using a vtable|
|COM Calls Using IDispatch|
|Runtime Callable Wrappers|
|Socket Bytes Sent|
|Socket Bytes Received|
|Graphics Created (FromImage)|
|Graphics Created (CreateGraphics)|
The statistics file includes running totals, the most recent value (last datum), count (n), average (mean), minimum and maximum values for the counters. I've included an example file at the end of this post. For counters where a given column is not relevant, a hyphen (-) is logged.
I will use the following format to describe each counter.
Brief description of the counter
Discussion of the contents of relevant columns (total, last datum, n, mean, min, max)
Any additional comments relating to the counter
Locks and Threads Counters
Writing well performing multi-threaded applications is one of the more challenging aspects of software development. Along with the performance considerations of single-threaded applications (memory usage, etc), thread scheduling and data access synchronization can impact how well your application performs. The counters described below can help identify threading related performance issues by providing data regarding thread, timer and lock usage during the run time of your application.
Threads in Thread Pool
The number of threads currently in the thread pool.
last datum: The current number of threads in the thread pool
n: The number of threads created in the thread pool
mean: The average number of threads in the thread pool during the run time of the application
min: The smallest number of threads in the thread pool during the run time of the application
max: The largest number of threads in the thread pool during the run time of the application
Please note: the Threads in Thread Pool counter does not count threads started using the Thread.Start method. Threads counted by this counter are those started via ThreadPool.QueueUserWorkItem.
The number of timers currently waiting to fire.
last datum: The current number of pending timers
n: The number of timer events which have been queued
mean: The average number of timers pending during the run time of the application
min: The fewest number of timers pending during the run time of the application
max: The largest number of timers pending during the run time of the application
The number of timers that are currently running for scheduled to run.
total: Running total of timers that have been scheduled during your application's run time
Timers Delayed by Thread Pool Limit
The count of timers that have been delayed by the thread pool limit.
total: Running total of timers that were waiting for a thread pool thread
Work Items Queued
The count of items queued to the thread pool.
total: Running total of all managed work items that have been queued to the thread pool.
Uncontested Monitor.Enter Calls
Count of calls made to Monitor.Enter that are not contested.
total: Running total of uncontested calls to Monitor.Enter
Contested Monitor.Enter Calls
Count of calls made to Monitor.Enter with lock contention.
total: Running total of contested calls to Monitor.Enter
In multi-threaded applications, if Thread1 is holding a lock and Thread2 needs to access code that is guarded by the lock (currently held by Thread1) the Contested Monitor.Enter Calls counter is incremented.
Example statistics file
I have highlighted the counters discussed here with a yellow background.
|Total Program Run Time (ms)||2956837||-||-||-||-||-|
|App Domains Created||1||-||-||-||-||-|
|App Domains Unloaded||1||-||-||-||-||-|
|Closed Types Loaded||75||-||-||-||-||-|
|Closed Types Loaded per Definition||75||3||22||3||1||10|
|Open Types Loaded||13||-||-||-||-||-|
|Closed Methods Loaded||3||-||-||-||-||-|
|Closed Methods Loaded per Definition||3||1||3||1||1||1|
|Open Methods Loaded||0||-||-||-||-||-|
|Threads in Thread Pool||-||0||2||0||0||1|
|Timers Delayed by Thread Pool Limit||0||-||-||-||-||-|
|Work Items Queued||2||-||-||-||-||-|
|Uncontested Monitor.Enter Calls||664||-||-||-||-||-|
|Contested Monitor.Enter Calls||0||-||-||-||-||-|
|Peak Bytes Allocated (native + managed)||2789048||-||-||-||-||-|
|Managed Objects Allocated||25883||-||-||-||-||-|
|Managed Bytes Allocated||1366120||24||25883||52||8||135796|
|Managed String Objects Allocated||5360||-||-||-||-||-|
|Bytes of String Objects Allocated||124412||-||-||-||-||-|
|Garbage Collections (GC)||1||-||-||-||-||-|
|Bytes Collected By GC||897140||897140||1||897140||897140||897140|
|Managed Bytes In Use After GC||-||147292||1||147292||147292||147292|
|Total Bytes In Use After GC||-||2621848||1||2621848||2621848||2621848|
|Calls to GC.Collect||0||-||-||-||-||-|
|GC Latency Time (ms)||46||46||1||46||46||46|
|Objects Moved by Compactor||0||-||-||-||-||-|
|Objects Not Moved by Compactor||0||-||-||-||-||-|
|Boxed Value Types||3273||-||-||-||-||-|
|Short Term Heap||-||0||6382||963||0||42136|
|App Domain Heap||-||0||18679||324926||0||523240|
|Native Bytes Jitted||844928||208||1963||430||84||9684|
|Method Pitch Latency Time (ms)||0||0||0||0||0||0|
|Platform Invoke Calls||0||-||-||-||-||-|
|COM Calls Using a vtable||0||-||-||-||-||-|
|COM Calls Using IDispatch||0||-||-||-||-||-|
|Runtime Callable Wrappers||0||-||-||-||-||-|
|Socket Bytes Sent||0||-||-||-||-||-|
|Socket Bytes Received||0||-||-||-||-||-|
|Graphics Created (FromImage)||0||-||-||-||-||-|
|Graphics Created (CreateGraphics)||0||-||-||-||-||-|
[Edit: update counter table to fix errors]
[Edit: post titles]
This posting is provided "AS IS" with no warranties, and confers no rights.