0

I am trying to evaluate the computational time using gprof. I compiled my code using the following command and then ran it, worked fine. But while trying to evaluate, its showing 0 cpu time.

a) gcc -pg -o process_basic process_basic.c

b) ./process_basic

c) gprof -b process_basic

Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00        5     0.00     0.00  display_int_var
  0.00      0.00     0.00        5     0.00     0.00  increment


Call graph


granularity: each sample hit covers 2 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00       5/5           main [10]
[1]      0.0    0.00    0.00       5         display_int_var [1]
                0.00    0.00       5/5           increment [2]
-----------------------------------------------
                0.00    0.00       5/5           display_int_var [1]
[2]      0.0    0.00    0.00       5         increment [2]
-----------------------------------------------


Index by function name

   [1] display_int_var         [2] increment

It also generated gmon.out and size was 601 bytes. I am using Ubuntu 18.04.2 LTS.

Any idea why the values are 0?

Vivek Roy
  • 21
  • 1
  • 1
    Because it took very short time to execute – klutt Aug 14 '20 at 11:00
  • If you would like to do a sanity check on your time measurement method, insert a temporary `sleep(10000);` call in a segment of your `C` code that you know is executed, eg. in the `main()` function. See if the elapsed time is reported accordingly. – ryyker Aug 14 '20 at 13:30

0 Answers0