Share via


Line Counting

How Do IDetails

Feature Only in Professional and Enterprise Editions   Profiling is supported only in Visual C++ Professional and Enterprise Editions. For more information, see .

The Line Counting option in the Profile dialog box 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.

Here is a sample of the output of a line counting profile run:

          Hit       
  Line    count   %   Source
-----------------------------------------------------
    1:                // test.c
    2:            
    3:                #include <windows.h>
    4:            
    5:                void WasteTime(HANDLE hInstance, HWND hWnd)
    6:     1     0.0  {
    7:                     LONG lCount, lX;
    8:                     HCURSOR hOldCursor;
    9:     1     0.0       hOldCursor = SetCursor(LoadCursor(NULL,
                                     IDC_WAIT));
   10:     1     0.0       for(lCount = 0; lCount < 1000L;  lCount++)  {
   11:  1000    49.9               lX = 57L;
   12:  1000    49.9       }
   13:     1     0.0       SetCursor(hOldCursor);
   14:     1     0.0 }

Note   All included source lines are printed, even if they are not executed.

Line counting profiling is very slow because the profiler inserts a debugging breakpoint for every source code line, and these breakpoints remain for the duration of the profile session. To speed up profiling, reduce the number of lines selected for profiling. For more information, see Select Code to Profile.