Build your project for profiling
For function profiling
- In the Visual Studio IDE take Project->Settings and it will display the Project Settings dialog box.
- Select the Link tab of Project Settings dialog box.
- Choose General in the Category drop-down list box.
- Check Enable Profiling check box and press OK button.
- Now build the project.
- Enable the function profiling as explained above.
- In the Link tab select the Generate Debug Info check box.
- Select the C/C++ tab and select the category drop-down list box as General.
- In the Debug Info drop-down list box, choose Program Database or Line Numbers Only.
- Click OK and re-build the project
Choose Build->Profile... from Visual Studio IDE menubar. In the Profile dialog displayed you can choose any of the available profiling types then application will run. After the operation quit the application and check the Visual Studio Output window. Following are different types of profiling,
- Function Timing - The Function Timing option in the Profile dialog box profiles the current project, recording how many times each function was called (hit count) as well as how much time was spent in each function and called functions.
- Function Coverage - profiling is useful for determining which sections of your code are not being executed. The profiler lists all profiled functions, with an asterisk (*) marking those that were executed.
- Function Counting - records how many times each function was called (hit count).
- Function Attribution - Function attribution records information about who called a particular function by taking a snapshot of the stack on each function call. See more details here.
- Line Counting - records how many times each line was called (hit count). To start a line count profile, use a custom batch file that specifies the source module and the lines to profile.
- Line Coverage - Line coverage profiling is useful for determining which sections of your code are not being executed. The profiler lists all profiled lines, with an asterisk (*) marking those that were executed.
Visual Studio 6.0 Profiler
Function Timing Profile sample output
Func Func+Child Hit
Time % Time % Count Function
---------------------------------------------------------
53153.728 99.5 53314.866 99.8 56 CWinThread::PumpMessage(void) (mfc42.dll)
136.579 0.3 136.964 0.3 176 CWnd::DefWindowProcA(unsigned int,unsigned int,long) (mfc42.dll)
Function Coverage Profile sample output
Covered Function
----------------
* AfxEnableControlContainer(class COccManager *) (mfc42.dll)
* AfxFindResourceHandle(char const *,char const *) (mfc42.dll)
* AfxInitialize(int,unsigned long) (appmodul.obj)
. AfxMessageBox(char const *,unsigned int,unsigned int) (mfc42.dll)
Note:By default Profiler profiles the entire dlls loaded and all .obj files linked. We can restrict the same by specifying exclude for unwanted libraries and obj files to be profiled. For that what you need to do is take the Profile.ini from Visual Studio installed location, Microsoft Visual Studio\VC98\Bin\Profile.ini
and add 'exclude:libraryname.lib' or 'ObjectFileName.obj'.See more profiling tips here.
No comments:
Post a Comment