CE6 - Capturing .NET Compact Framework application statistics.
You’ve just finished writing the worlds most amazing .NET Compact Framework application running on Windows Embedded CE 6.0, the application does everything apart from making a nice cup of hot tea. But how well does the application perform? Writing .NET code is great, the class libraries make you super productive, and unlike C++ development you don’t need to worry about pointers or the lifetime of the objects you create, the Garbage Collector sweeps up behind you, right? Sure, absolutely, but that doesn’t mean that you should be a lazy programmer, writing in high level languages doesn’t mean that you shouldn’t care about the performance of your application. Do you know how many objects are created/disposed during the runtime of your application, or how many methods are Jitted, or Code Pitched? – why not? – probably because you’ve not seen how to capture this useful information.
The process for capturing useful application statistics is extremely simple – you just need to set one registry key on your device – in this case I’ve added the registry key to my CE 6.0 operating system image, and have written a very simple .NET Compact Framework 3.5, C#, WinForms based application that has two buttons, 1) Allocate 10k objects, and 2) Exit – the application is called SimpleCFApp (obviously!).
Here’s the registry key:
[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETCompactFramework\PerfMonitor]
"Counters"=dword:1
The output from the application is stored in the root of your devices file system and is named “YourApplicationName”.stat – so for my application I get a file called \SimpleCFApp.stat
Here’s the output from my simple application…
Counter total last datum n mean min max
Total Program Run Time (ms) 34044 - - - - -
App Domains Created 1 - - - - -
App Domains Unloaded 1 - - - - -
Assemblies Loaded 5 - - - - -
Classes Loaded 291 - - - - -
Methods Loaded 425 - - - - -
Closed Types Loaded 0 - - - - -
Closed Types Loaded per Definition 0 0 0 0 0 0
Open Types Loaded 1 - - - - -
Closed Methods Loaded 0 - - - - -
Closed Methods Loaded per Definition 0 0 0 0 0 0
Open Methods Loaded 0 - - - - -
Threads in Thread Pool - 0 0 0 0 0
Pending Timers - 0 0 0 0 0
Scheduled Timers 0 - - - - -
Timers Delayed by Thread Pool Limit 0 - - - - -
Work Items Queued 0 - - - - -
Uncontested Monitor.Enter Calls 10 - - - - -
Contested Monitor.Enter Calls 0 - - - - -
Peak Bytes Allocated (native + managed) 281094 - - - - -
Managed Objects Allocated 184 - - - - -
Managed Bytes Allocated 6152 32 184 33 8 576
Managed String Objects Allocated 29 - - - - -
Bytes of String Objects Allocated 492 - - - - -
Garbage Collections (GC) 0 - - - - -
Bytes Collected By GC 0 0 0 0 0 0
Managed Bytes In Use After GC - 0 0 0 0 0
Total Bytes In Use After GC - 0 0 0 0 0
GC Compactions 0 - - - - -
Code Pitchings 0 - - - - -
Calls to GC.Collect 0 - - - - -
GC Latency Time (ms) 0 0 0 0 0 0
Pinned Objects 0 - - - - -
Objects Moved by Compactor 0 - - - - -
Objects Not Moved by Compactor 0 - - - - -
Objects Finalized 4 - - - - -
Objects on Finalizer Queue - 0 21 10 0 20
Boxed Value Types 0 - - - - -
Process Heap - 422 707 10924 312 20778
Short Term Heap - 0 128 801 0 30752
JIT Heap - 0 828 35910 0 71725
App Domain Heap - 1536 238 87004 1536 125625
GC Heap - 0 2 32768 0 65536
Native Bytes Jitted 64504 216 224 287 84 3568
Methods Jitted 224 - - - - -
Bytes Pitched 0 0 0 0 0 0
Methods Pitched 0 - - - - -
Method Pitch Latency Time (ms) 0 0 0 0 0 0
Exceptions Thrown 0 - - - - -
Platform Invoke Calls 0 - - - - -
COM Calls Using a vtable 0 - - - - -
COM Calls Using IDispatch 0 - - - - -
Complex Marshaling 0 - - - - -
Runtime Callable Wrappers 0 - - - - -
Socket Bytes Sent 0 - - - - -
Socket Bytes Received 0 - - - - -
Controls Created 4 - - - - -
Brushes Created 1 - - - - -
Pens Created 0 - - - - -
Bitmaps Created 0 - - - - -
Regions Created 0 - - - - -
Fonts Created 2 - - - - -
Graphics Created (FromImage) 0 - - - - -
Graphics Created (CreateGraphics) 0 - - - - -
Obviously this is a really simple application, application statistics may be more interesting for a slightly more complex application.
- Mike
Comments
Anonymous
February 19, 2009
PingBack from http://www.clickandsolve.com/?p=11706Anonymous
March 03, 2009
Nice post Mike and I can guess the actual data you captured was way more interesting ;)