bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help-using gnu's gprof for getting profiling information


From: Rakesh M. Patel
Subject: help-using gnu's gprof for getting profiling information
Date: Tue, 30 Mar 2004 20:11:00 -0600

Hi,

  I am using gnu's gprof for getting profiling information for given source 
code. Basically my concern is to know how many times each line in the source 
code executed.

 In my source file i have the for loop as shown below

     void increment(int x)
           {
                int y = 0;
                int i = 0;                      
                for(i = 0; i < 10000000; i++)
                        x = x + 1;
           
                decrement(x);
           }

 Now i am compiling my source code using following sequence

    gcc -c *.c -g -pg -a
    gcc -o run *.o -g -pg -a
    run

 After executing above sequence i do have a file gmon.out in the current 
directory.

 For getting profiling information (annotated source listing) i am using 
following command.
 
   gprof -A -l -x run gmon.out > profile.txt

 I think above command will help to know how many times each line in the source 
code been executed. But above command produces following output.

        void increment(int x)
           1 -> {
           1 ->         int y = 0;
           1 ->         int i = 0;                      
           1 ->         for(i = 0; i < 10000000; i++)
           1 ->                 x = x + 1;                
           1 ->         decrement(x);                   
           1 -> }

  It seems that the count on the line x = x + 1 should be 10000000, instead of 
1....If above thing is true than how can i get the total count stating the no 
of times each line is executed.


Can anyone helps me out to solve this problem.

Waiting for the your help....

Rakesh Patel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]