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

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

gprof shows longer total time than actual


From: Antonios Christofides
Subject: gprof shows longer total time than actual
Date: Mon, 04 Oct 2004 16:20:22 -0000
User-agent: slrn/0.9.8.0 (Linux)

Hi, 

I'm new to gprof. I'm compiling my program with -pg -fprofile-arcs and
use gprof to see where time is spent (gcc 3.3.2, gprof 2.14.90.0.7,
linux 2.6.7).

But while my program takes 1.7 seconds to run, gprof indicates a total
time of 4.6 seconds. If I give the program 10 times more data, it runs
in 17 seconds and gprof indicates total time about 45 seconds.
Likewise, if I give it 10 times less data, it runs in 0.17 seconds and
gprof shows total time about 0.5 seconds. In another machine (gcc
2.95.4, gprof 2.12.90.0.1, linux 2.4.18), the program takes 1.7
seconds and gprof indicates 0.40 seconds. The number of calls is
always correct.

What have I understood wrong? I understand that the analysis has
statistical errors, but isn't the total time given? Since the program
runs in 1.7 seconds, doesn't the profiler take 170 samples? Shouldn't
gprof see that we have samples that correspond to 1.7 seconds? I
include the entire gprof output below.

Thanks!



Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 27.47      1.26     1.26  1224288     0.00     0.00  csvtok
 21.01      2.22     0.96   306074     0.00     0.00  parsedatestring
 18.82      3.08     0.86   306072     0.00     0.00  append_record
 12.91      3.67     0.59        1     0.59     4.51  ts_readfile
 11.93      4.21     0.55   918216     0.00     0.00  strip
  4.82      4.43     0.22   306073     0.00     0.00  tmcmp
  1.75      4.51     0.08   306072     0.00     0.00  check_block_size
  0.44      4.53     0.02                             find_end_quote
  0.33      4.55     0.02                             csvquote
  0.22      4.56     0.01        1     0.01     0.01  global constructors keyed 
to errorexitGCOV
  0.22      4.57     0.01                             add_minutes
  0.11      4.57     0.01        1     0.01     0.01  global constructors keyed 
to stripGCOV
  0.00      4.57     0.00        1     0.00     0.00  global constructors keyed 
to append_recordGCOV
  0.00      4.57     0.00        1     0.00     0.00  global constructors keyed 
to csvtokGCOV
  0.00      4.57     0.00        1     0.00     0.00  global constructors keyed 
to month_daysGCOV
  0.00      4.57     0.00        1     0.00     0.00  delete_between
  0.00      4.57     0.00        1     0.00     4.51  do_delete
  0.00      4.57     0.00        1     0.00     0.00  get_next
  0.00      4.57     0.00        1     0.00     0.00  get_prev
  0.00      4.57     0.00        1     0.00     0.00  ts_writefile

 %         the percentage of the total running time of the
time       program used by this function.

cumulative a running sum of the number of seconds accounted
 seconds   for by this function and those listed above it.

 self      the number of seconds accounted for by this
seconds    function alone.  This is the major sort for this
           listing.

calls      the number of times this function was invoked, if
           this function is profiled, else blank.
 
 self      the average number of milliseconds spent in this
ms/call    function per call, if this function is profiled,
           else blank.

 total     the average number of milliseconds spent in this
ms/call    function and its descendents per call, if this 
           function is profiled, else blank.

name       the name of the function.  This is the minor sort
           for this listing. The index shows the location of
           the function in the gprof listing. If the index is
           in parenthesis it shows where it would appear in
           the gprof listing if it were to be printed.

                     Call graph (explanation follows)


granularity: each sample hit covers 2 byte(s) for 0.22% of 4.57 seconds

index % time    self  children    called     name
                0.00    4.51       1/1           main [2]
[1]     98.7    0.00    4.51       1         do_delete [1]
                0.59    3.92       1/1           ts_readfile [3]
                0.00    0.00       2/306074      parsedatestring [6]
                0.00    0.00       1/1           delete_between [16]
                0.00    0.00       1/1           ts_writefile [19]
-----------------------------------------------
                                                 <spontaneous>
[2]     98.7    0.00    4.51                 main [2]
                0.00    4.51       1/1           do_delete [1]
-----------------------------------------------
                0.59    3.92       1/1           do_delete [1]
[3]     98.7    0.59    3.92       1         ts_readfile [3]
                1.26    0.00 1224288/1224288     csvtok [4]
                0.86    0.30  306072/306072      append_record [5]
                0.96    0.00  306072/306074      parsedatestring [6]
                0.55    0.00  918216/918216      strip [7]
-----------------------------------------------
                1.26    0.00 1224288/1224288     ts_readfile [3]
[4]     27.5    1.26    0.00 1224288         csvtok [4]
-----------------------------------------------
                0.86    0.30  306072/306072      ts_readfile [3]
[5]     25.4    0.86    0.30  306072         append_record [5]
                0.22    0.00  306071/306073      tmcmp [8]
                0.08    0.00  306072/306072      check_block_size [9]
-----------------------------------------------
                0.00    0.00       2/306074      do_delete [1]
                0.96    0.00  306072/306074      ts_readfile [3]
[6]     21.0    0.96    0.00  306074         parsedatestring [6]
-----------------------------------------------
                0.55    0.00  918216/918216      ts_readfile [3]
[7]     11.9    0.55    0.00  918216         strip [7]
-----------------------------------------------
                0.00    0.00       1/306073      get_next [17]
                0.00    0.00       1/306073      get_prev [18]
                0.22    0.00  306071/306073      append_record [5]
[8]      4.8    0.22    0.00  306073         tmcmp [8]
-----------------------------------------------
                0.08    0.00  306072/306072      append_record [5]
[9]      1.8    0.08    0.00  306072         check_block_size [9]
-----------------------------------------------
                                                 <spontaneous>
[10]     0.4    0.02    0.00                 find_end_quote [10]
-----------------------------------------------
                                                 <spontaneous>
[11]     0.3    0.02    0.00                 csvquote [11]
-----------------------------------------------
                                                 <spontaneous>
[12]     0.3    0.00    0.02                 __do_global_ctors_aux [12]
                0.01    0.00       1/1           global constructors keyed to 
errorexitGCOV [14]
                0.01    0.00       1/1           global constructors keyed to 
stripGCOV [15]
                0.00    0.00       1/1           global constructors keyed to 
month_daysGCOV [33]
                0.00    0.00       1/1           global constructors keyed to 
append_recordGCOV [31]
                0.00    0.00       1/1           global constructors keyed to 
csvtokGCOV [32]
-----------------------------------------------
                                                 <spontaneous>
[13]     0.2    0.01    0.00                 add_minutes [13]
-----------------------------------------------
                0.01    0.00       1/1           __do_global_ctors_aux [12]
[14]     0.2    0.01    0.00       1         global constructors keyed to 
errorexitGCOV [14]
-----------------------------------------------
                0.01    0.00       1/1           __do_global_ctors_aux [12]
[15]     0.1    0.01    0.00       1         global constructors keyed to 
stripGCOV [15]
-----------------------------------------------
                0.00    0.00       1/1           do_delete [1]
[16]     0.0    0.00    0.00       1         delete_between [16]
                0.00    0.00       1/1           get_next [17]
                0.00    0.00       1/1           get_prev [18]
-----------------------------------------------
                0.00    0.00       1/1           delete_between [16]
[17]     0.0    0.00    0.00       1         get_next [17]
                0.00    0.00       1/306073      tmcmp [8]
-----------------------------------------------
                0.00    0.00       1/1           delete_between [16]
[18]     0.0    0.00    0.00       1         get_prev [18]
                0.00    0.00       1/306073      tmcmp [8]
-----------------------------------------------
                0.00    0.00       1/1           do_delete [1]
[19]     0.0    0.00    0.00       1         ts_writefile [19]
-----------------------------------------------
                0.00    0.00       1/1           __do_global_ctors_aux [12]
[31]     0.0    0.00    0.00       1         global constructors keyed to 
append_recordGCOV [31]
-----------------------------------------------
                0.00    0.00       1/1           __do_global_ctors_aux [12]
[32]     0.0    0.00    0.00       1         global constructors keyed to 
csvtokGCOV [32]
-----------------------------------------------
                0.00    0.00       1/1           __do_global_ctors_aux [12]
[33]     0.0    0.00    0.00       1         global constructors keyed to 
month_daysGCOV [33]
-----------------------------------------------

 This table describes the call tree of the program, and was sorted by
 the total amount of time spent in each function and its children.

 Each entry in this table consists of several lines.  The line with the
 index number at the left hand margin lists the current function.
 The lines above it list the functions that called this function,
 and the lines below it list the functions this one called.
 This line lists:
     index      A unique number given to each element of the table.
                Index numbers are sorted numerically.
                The index number is printed next to every function name so
                it is easier to look up where the function in the table.

     % time     This is the percentage of the `total' time that was spent
                in this function and its children.  Note that due to
                different viewpoints, functions excluded by options, etc,
                these numbers will NOT add up to 100%.

     self       This is the total amount of time spent in this function.

     children   This is the total amount of time propagated into this
                function by its children.

     called     This is the number of times the function was called.
                If the function called itself recursively, the number
                only includes non-recursive calls, and is followed by
                a `+' and the number of recursive calls.

     name       The name of the current function.  The index number is
                printed after it.  If the function is a member of a
                cycle, the cycle number is printed between the
                function's name and the index number.


 For the function's parents, the fields have the following meanings:

     self       This is the amount of time that was propagated directly
                from the function into this parent.

     children   This is the amount of time that was propagated from
                the function's children into this parent.

     called     This is the number of times this parent called the
                function `/' the total number of times the function
                was called.  Recursive calls to the function are not
                included in the number after the `/'.

     name       This is the name of the parent.  The parent's index
                number is printed after it.  If the parent is a
                member of a cycle, the cycle number is printed between
                the name and the index number.

 If the parents of the function cannot be determined, the word
 `<spontaneous>' is printed in the `name' field, and all the other
 fields are blank.

 For the function's children, the fields have the following meanings:

     self       This is the amount of time that was propagated directly
                from the child into the function.

     children   This is the amount of time that was propagated from the
                child's children to the function.

     called     This is the number of times the function called
                this child `/' the total number of times the child
                was called.  Recursive calls by the child are not
                listed in the number after the `/'.

     name       This is the name of the child.  The child's index
                number is printed after it.  If the child is a
                member of a cycle, the cycle number is printed
                between the name and the index number.

 If there are any cycles (circles) in the call graph, there is an
 entry for the cycle-as-a-whole.  This entry shows who called the
 cycle (as parents) and the members of the cycle (as children.)
 The `+' recursive calls entry shows the number of function calls that
 were internal to the cycle, and the calls entry for each member shows,
 for that member, how many times it was called from other members of
 the cycle.


Index by function name

  [31] global constructors keyed to append_recordGCOV [9] check_block_size [18] 
get_prev
  [32] global constructors keyed to csvtokGCOV [11] csvquote [6] parsedatestring
  [14] global constructors keyed to errorexitGCOV [4] csvtok [7] strip
  [33] global constructors keyed to month_daysGCOV [16] delete_between [8] tmcmp
  [15] global constructors keyed to stripGCOV [1] do_delete [3] ts_readfile
  [13] add_minutes            [10] find_end_quote         [19] ts_writefile
   [5] append_record          [17] get_next



reply via email to

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