Edit: I ran the real program and got this:
% time real_program real 4m24.107s user 2m34.630s sys 0m38.716s Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalEdit: I ran the real program and got this:
% time real_program real 4m24.107s user 2m34.630s sys 0m38.716s Edit: I ran the real program and got this:
% time real_program real 4m24.107s user 2m34.630s sys 0m38.716s I need to profile a program to see whether any changes need to be made regarding performance. I suspect there is a need, but measuring first is the way to go. This is not that program, but it illustrates the problem I'm having:
#include <stdio.h> int main (int argc, char** argv) { FILE* fp = fopen ("trivial.c", "r"); if (fp) { char line[80]; while (fgets (line, 80, fp)) printf (line); fclose (fp); } return 0; } Here's what I did with it:
% gcc trivial.c -pg -o trivial % ./trivial ... % gprof trivial gmon.out Granted, this is a trivial program, but I would have thought it would make some kind of blip on the profiling radar. It didn't:
called/total parents index %time self descendents called+self name index called/total children 0.00 0.00 1/1 __start [1704] [105] 0.0 0.00 0.00 1 _main [105] ----------------------------------------------- % cumulative self self total time seconds seconds calls ms/call ms/call name 0.0 0.00 0.00 1 0.00 0.00 _main [105] Index by function name [105] _main Can anyone guide me here? I would like the output to reflect that it called fgets and printf at least 14 times, and it did hit the disk after all - there should be some measured time, surely.
When I run the same command on the real program, I get more functions listed, but even then it is not a complete list - just a sample.
Perhaps gprof is not the right tool to use. What is?
This is on OS X Leopard.