Profiling an Application in Microsoft Windows
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
The information in this article is included in the documentation startingwith Visual C++ 5.0. Look there for future revisions.
Version 1.2 of the Microsoft Source Profiles includes two executablefiles: PROFILE.EXE and PROFILEW.EXE. PROFILEW.EXE is a MicrosoftWindows-hosted source profile utility that can run from the commandline or from an icon in the Microsoft Windows operating system. Thenames of batch files used to profile a Windows-based application endwith the letter "W." Run these batch files from the MS-DOS promptbecause each one starts Windows. You also can profile a Windows-basedapplication in Windows.
The text below provides the steps to profile function timing in theGENERIC sample application provided with the Microsoft WindowsSoftware Development Kit (SDK). The explanation assumes that theGENERIC sample is installed in the C:\WINDEV\GUIDE\GENERIC directoryand that the Source Profiler is installed in the C:\PROFILER\BINdirectory. The procedure has three main steps, as follows:
- Create the PCF file and run PREP.
- Create an icon for profiling and profile the application.
- Create an output file with PREP and PLIST.
Create the PCF and Run PREP
The PCF (Profiler Command File) provides greater control to select theparts of the executable program to profile. The PCF is optional and isnot necessary to collect statistics about all functions of theapplication.
With the following PCF, the profiler collects statistics only for themain window procedure and for the About dialog box procedure inGENERIC. For more information on PCFs, see chapter 4 of the SourceProfiler "User's Guide." Place the following text into the GENERIC.PCFfile:
FPROFILE TIME PROGRAM GENERIC.EXE DELETE OBJECT GENERIC.OBJ FUNCTION MainWndProc ADD # Note: function names are case sensitive FUNCTION About ADD
To use this file, perform the following three steps:
- Place the GENERIC.PCF file into the same directory as the source code for the GENERIC sample.
- Build the GENERIC sample with debugging information (specify the /Zi compiler option switch and the /CO linker option switch).
- Use the following command line to run the PREP utility:
PREP /P GENERIC.EXE /OT GENERIC.PBT /OI GENERIC.PBI GENERIC.PCF
For more information about the PREP utility, see Appendix A of theSource Profiler "User's Guide."
You can place the PREP command into the makefile that builds profilingversions of your application. Run the PREP utility after building theexecutable file.
Create an Icon for Profiling and Profile the Application
Perform the following seven steps:
- In the Microsoft Windows Program Manager, activate a program group.
- Choose New from the File menu.
- Choose OK to create a new program item.
- In the Properties dialog box, enter the following text in the Command Line field:
PROFILEW C:\WINDEV\GUIDE\GENERIC\GENERIC.EXE Note: This command line assumes that the PBI and PBO files are named GENERIC.PBI and GENERIC.PBO, respectively, and that each resides in the C:\WINDEV\GUIDE\GENERIC directory.
- In the Working Directory field, enter the path to the PROFILEW.EXE file. In this example, the correct directory is C:\PROFILEW\BIN.
- Choose OK to create the program icon.
- To run and profile GENERIC, either double-click the icon or select the icon and choose Run from the File menu. Close GENERIC to complete profiling.
Create an output File with PREP and PLIST
Perform the following two steps:
- At the MS-DOS prompt, enter the following command to update the PBT file:
PREP /IT GENERIC.PBT /IO GENERIC.PBO /OT GENERIC.PBT
- At the MS-DOS prompt, enter the following command to create an output text file:
PLIST GENERIC.PBT > GENERIC.TXT
For more information about the PLIST utility, see Appendix A of theSource Profiler "User's Guide."
Even though GENERIC.TXT lists all the functions in the GENERICapplication, it contains timing and hit statistics for only theAbout() and MainWndProc() functions.
1.00 1.20 1.30
Article ID: 94209 - Last Review: 06/17/2014 21:45:00 - Revision: 3.0