Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get gprof to profile based on wall-clock time?

My understanding is that by default gprof takes into account CPU time. Is there a way to get it to profile based on wall-clock time?

My program does a lot of disk i/o, so the CPU time it uses only represents a fraction of the actual execution time. I need to know which portions of the disk i/o take up the most time.

like image 823
jetwolf Avatar asked May 10 '10 15:05

jetwolf


3 Answers

You can measure wall-clock time by using profiler from google-perftools. To switch google profiler to wall-clock mode, set the environment variable CPUPROFILE_REALTIME=1.

like image 148
dronnix Avatar answered Oct 27 '22 20:10

dronnix


gprof won't do this. Look at this.

And this.

In a nutshell: Under gdb, get it running and do Ctrl-Break or Ctrl-C 10 times at random, and display the call stack. If your I/O is taking (for example) 60% of the time, then on (roughly) 6 out of 10 pauses, you will see it in the writebuf or readbuf routine, and the lines of code requesting that I/O will be clearly displayed on the stack.

You could also use lsstack to get the same information.

like image 40
Mike Dunlavey Avatar answered Oct 27 '22 19:10

Mike Dunlavey


You can use strace or cachegrind to profile the code properly. strace will give you details of time spent in system calls and cachegrind will give detailed analysis of resource utilization.

like image 1
Rohit Avatar answered Oct 27 '22 20:10

Rohit