Sunday, November 7, 2010

Profiling , A Performance Tuning method

Title -Profiling ,  A Performance Tuning method

Tip -The profiler is an analysis tool that you can use to examine the run-time behavior of your programs. By using profiler information, you can determine which sections of your code are working efficiently. The profiler can produce information showing areas of code that are not being executed or that are taking a long time to execute.
Because profiling is a tuning process, you should use the profiler to make your programs run better, not to find bugs. Once your program is fairly stable, you should start profiling to see where your code could perform better.

Details -Use the profiler to determine whether,
    * an algorithm is effective (timing),
    * a function is being called too many or too few times with respect to the problem domain (counting), or
    * a piece of code is being covered by software testing procedures (coverage).

Build the project for profiling :
Before using the profiler, you must build the current project with profiling enabled (equivalent to the command line setting LINK /PROFILE). If you want to perform function profiling only in the current project, you only need to enable profiling for the linker. If you want to do line profiling, you also need to include debugging information.

To build your project for function profiling
   1. On the Build menu, click Settings to display the Project Settings dialog box.
   2. Click the Link tab.
   3. In the Category drop-down list box, click General.
   4. Select the Enable Profiling check box.
   5. Click OK.
   6. On the Build menu, click Buildprojectname.exe.
Note   Selecting the Enable Profiling check box turns off incremental linking. To re-enable incremental linking, clear the Enable Profiling option.
To build your project for line profiling
   1. Perform the procedure to enable function profiling described earlier in this topic.
   2. Select the Generate Debug Info check box.
   3. Click the C/C++ tab.
   4. In the Category drop-down list box, click General.
   5. In the Debug Info drop-down list box, click Program Database or Line Numbers Only.
   6. Click OK.
   7. On the Build menu, click Buildprojectname.exe.
When the build is complete, the project is ready to be profiled.

To run the profiler from the development environment
On the Build menu, choose Profile to display the Profile dialog box

   1. In the Profile Type box, click one of the following option buttons:
          * Function Timing
          * Function Coverage
          * Line Coverage
          * Merge
          * Use Custom and the Custom Settings text box to run a batch file that contains profiler commands. See Run the Profiler from the Command Line for information on why you might want to batch and execute your own profiler commands. See Running a Custom Batch File for more information on specifying a batch file from the development environment.
          * Advanced settings is where you can specify PREP Phase I options.
   2. Click OK.

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) 
136.579       0.3      136.964      0.3     176   CWnd::DefWindowProcA(unsigned int,unsigned int,long)

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)

Reference :

Posted By : Febil Chacko

No comments:

Post a Comment