Monitoring Application Performance on the .NET Compact Framework Part I – Enabling performance counters

Today's post is the first in a series on monitoring application performance on the .NET Compact Framework.  In this installment, I will discuss how to enable the performance counters.  Later in this series, I will be talking about the counters themselves and how you can use the data collected.

To enable the performance counters, you will need to modify the device's registry.  In my steps, below, I will be using the Remote Registry Editor that is included with Visual Studio 2005.

WARNING: Using Remote Registry Editor incorrectly can cause serious problems that may require you to hard reset your device. Microsoft cannot guarantee that problems resulting from the incorrect use of Remote Registry Editor can be solved. Use Remote Registry Editor at your own risk.

  1. Start the Remote Registry Editor

    • Open the Start Menu
    • Select All Programs
    • Select Microsoft Visual Studio 2005
    • Select Visual Studio Remote Tools
    • Select Remote Registry Editor

  2. Connect to your device

    • On the Target menu, select Connect
    • Select your device and click OK

  3. Enable performance monitors

    • In the left hand pane, expand the device
    • Expand SOFTWARE
    • Expand Microsoft
    • Expand .NETCompactFramework
    • Expand PerfMonitor
      If this key does not exist, you will need to create it

      • Right click on .NETCompactFramework
      • Select New > Key
      • Type "PerfMonitor" (without quotes)
      • Click OK

    • Set the value of Counters to 1
      If this value does not exist, you will need to create it

      • Right click on PerfMonitor
      • Select New > DWORD Value
      • Set the Name to Counters
      • Set the value to 1
      • Click OK

To disable performance counters, follow the above steps and set the value of Counters to 0.

In version 1 of the .NET Compact Framework, the counter data is written to a file (in the device's root folder) called mscoree.stat.  For version 2, the file has is named to match that of your application.  For example, running webcrawler.exe while performance counters are enabled will cause a file named webcrawler.stat to be created in the device root folder.

When collecting performance data, there are a few things to note:

  1. The counter data file is created when your application exits
    Analysis of the performance counter data is performed "after the fact".
  2. Your application will run slower while the performance data is being collected
    Disable performance counter collection once you have collected your desired statistics.
  3. When running on version 1 of the .NET Compact Framework, for the data to be accurate, run only one (1) managed application at a time
    This is an issue only on version 1 due to the fact that the statistics file is always called mscoree.stat.  For version 2, the statisics file is named after your application which allows collection for multiple applications simultaneously.

Take care,
-- DK

[Edit: post title]

This posting is provided "AS IS" with no warranties, and confers no rights.

Comments (3)

  1. David Kline says:

    Steven Pratschner recently posted about one of the coolest new features of the Service Pack 1 beta for…

  2. Hace ya algún tiempo mencioné en este mismo blog que con la llegada del Path SP1 para CF 2.0 ívamos…

Skip to main content