How to profile a windows Service using Performance or Coverage Analysis?

0 Likes

Problem:

How to get Performance or Coverage profiling data for a Windows Service using DPS 7.X

Resolution:

First, make sure that your service is allowed to interactive with desktop

(from the Service properties page, check 'Allow service interactive with desktop'').

For Windows Service written in unmanaged code:

.Instrument the service with Performance Analysis or Coverage Analysis

.Register the service

* Please note: During the registration, if you see a session control window for regsvr32.exe, just ignore it (them).

.Start the service

When you start the instrumented service, you should see the performance or coverage session control window for your service.

For Windows service written in managed code (assuming that the service is build and registered):

If the service is hosted by SVCHOST.exe, please set the following environment variables under system or user account:

For Performance Analysis profiling:

COR_ENABLE_PROFILING=1

COR_PROFILER={372DC2B6-0A34-4f22-BC34-BE7A18DE9137}

For Coverage Analysis:

COR_ENABLE_PROFILING=1

COR_PROFILER={372DC2B6-0A34-4f22-BC34-BE7A18DE9137}

NM_DOING_COVERAGE=1

Then reboot your machine to take effects. You can find out the above environment variables in AnalysisCommonEnv.bat file:

[Root]:\Program Files\Compuware\DevPartner Performance and Coverage\Analysis\AnalysisCommonEnv.bat

If the service is not hosted by SVCHOST.exe, there is no need to reboot the machine. Or you can either run the AnalysisCommonEnv.bat file from the command line to set the above environment variables then start the service from the same command line. Remember to add /Coverage when you run AnalysisCommonEnv.bat file for Coverage Analysis profiling.

When the service starts, you should get a session control for the service which will allow you to take snapshots.

Note:

Please remove these environment variables after you've done profiling. Otherwise, Performance /Coverage Analysis will profile any running .NET application.

Old KB# 11818
Comment List
Anonymous
Related Discussions
Recommended