Analyzing Device Application Performance with the .Net Compact Framework Remote Performance Monitor
Service Pack 1 of the .Net Compact Framework version 2 (see https://blogs.msdn.com/netcfteam/archive/2006/04/21/580901.aspx) includes a new utility called the .Net Compact Framework Remote Performance Monitor (RPM). The RPM helps you diagnose performance problems in your application by providing a dynamic, graphical view of various runtime performance statistics. The performance statistics displayed by the RPM are those that are present in the ".stat" files in previous versions of the Compact Framework. See David Kline's blog entry "Monitoring Application Performance..." for a thorough description of all the counters viewable through the RPM.
You have two choices when viewing data using RPM. First, you can view the counters in a textual table format using the RPM tool itself, or you can view all the data the RPM gathers using the standard Windows Performance Monitor.
This post provides instructions for installing and using the RPM. This tool is a big step forward for .Net Compact Framework developers. For the first time, you'll be able to to use standard performance tools to gain insight into your application's performance as it runs!
The .Net CF Remote Performance Monitor includes some files that reside on the desktop machine and some files that must be present on the device.
Installing the desktop components is easy - just run the SP1 setup program. After the installation completes, the RPM executable (netcfrpm.exe) is placed in the bin directory of Compact Framework SDK. On my machine, this directory is C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\bin.
Installing the device-side components involves manually copying two files from the desktop machine to the device. The SP1 setup program places the device-side files in the same directory as the cab file that matches your processor type and operation system version. I have a Pocket PC 2003 SE device, so my device-side components are installed in C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\wce400\armv4. The two files you must copy are netcfrtl.dll and netcflaunch.exe. Both of these files must be copied to the \windows directory of your device.
Installation Notes for Windows Mobile 5.0 Devices
There are two issues you may run into when installing the device-side RPM components on Windows Mobile 5.0 devices.
- Depending on the security configuration chosen by the device manufacturer, you may see a security prompt on the device the first time you launch the RPM. This prompt appears because netcfrpm.dll is not signed.
- An additional installation step is necessary on Windows Mobile 5.0 devices to provision the device so the RPM can run. Provisioning involves copying the following XML text into a file and using the rapiconfig utility to send the XML file to the device.
- <characteristic type="Metabase">
- <characteristic type="RAPI\Windows\netcfrtl.dll\*">
<parm name="rw-access" value="3" />
<parm name="access-role" value="152" />
<!-- 152 maps to "CARRIER_TPS | USER_AUTH | MANAGER"-->
For example, if you pasted the above XML text into a file named rpmprov.xml you'd issue the following command from your desktop machine to provision your device:
rapiconfig /p rpmprov.xml
Launching the Remote Performance Monitor
To view dynamic performance statistics for your application, launch netcfrpm.exe from the desktop machine and select the "Live Counters...." option under the File menu. Doing so displays the following window:
Before you can view live statistics, you must connect the RPM to your device and specify the application you'd like to run. The instructions for connecting the RPM to your device vary based on whether the connection between your desktop machine and your device is via Active Sync or an Ethernet connection. If your connection is over ActiveSync, your device will automatically appear in the Device drop down in the RPM user interface. If your desktop machine is connected to the device through a direct network connection, you must know the IP address and port number through which the RPM can connect to your device. This information can be obtained by running netcflauch.exe from the \windows directory of your device. Running netcflaunch.exe displays the following:
Using the data displayed by netcflaunch.exe, enter the IP address and port number in format <IPAddress><single space><port number> in the Device drop down in the RPM user interface.
Before connecting to the device, you must specify the application you'd like to monitor using the Application text box. Be sure to type the fully qualified path name to the executable you wish to run on the device. For example, \Program Files\poomcominterop\poomcominterop.exe. If your applications takes command line parameters, you can specify them in the Parameters text box. If you need to specify more than one parameter, be sure to separate them with a space.
After you've selected the device to connect to, and specified the application to launch, click the Connect button in the lower right corner of RPM's user interface. The RPM will send a command to the device to remotely launch the application and start pulling back performance statistics. RPM displays the statistics in tabular form as shown in the following picture:
Again, a description of the various counters can be found on David Kline's blog.
Viewing Performance Statistics using Perfmon
While viewing performance statistics in RPM is useful, it's often easier to spot performance trends by viewing the data in a graphical form. The RPM enables you to view the statistics graphically by sending all the data it collects to the Windows Performance Monitor. After opening performance monitor, select the "Add Counter" option. In the dialog that is displayed you'll see counters corresponding to each category of performance statistic gathered by the RPM as show below:
After selecting the counters you'd like to view, the values for those counters appear as a line in the Perfmon graph. You may need to adjust the scale Perfmon uses to display a counter depending on the expected range of values. In the picture below I've chosen to view counters representing the size of the GC heap and the total number of bytes allocated while my application runs.
Other RPM Features
In addition to viewing performance statistics, the RPM also allows you to set various configuration options for your device. Selecting the Logging Options item from the Device menu displays the following dialog:
As you can see, the RPM allows you to configure the various types of logging done by the Compact Framework and to put your device into a state in which you can attach the debugger to any managed process. The following links provide more information about the various logging options:
- Loader logging: https://blogs.msdn.com/stevenpr/archive/2005/02/28/381744.aspx
- Interop logging: https://blogs.msdn.com/stevenpr/archive/2005/06/22/431612.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.