Results 1 to 6 of 6
Hi,,
the gprof tool in order to get the information, the application should return from main() or call exit(). what if a program runs into a while loop all the ...
- 07-16-2008 #1Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
profiling "gprof" inquiry??
Hi,,
the gprof tool in order to get the information, the application should return from main() or call exit(). what if a program runs into a while loop all the time i.e. while(1)
how we can get over this issue to generate "gmon.out" ??
thanks
- 07-17-2008 #2
I did this at the command line:
and got text which included this:Code:man gprof
So it would seem that your only way to solve this is to grab the gprof code and add a new feature.Code:The profiled program must call "exit"(2) or return nor- mally for the profiling information to be saved in the gmon.out file.--
Bill
Old age and treachery will overcome youth and skill.
- 07-17-2008 #3Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
- 07-17-2008 #4
The only alternative that comes to mind is to place code within each function that modifies a global count and a global number of runtime seconds or microseconds.
What might make that easier is to define two macros: one which is used at the beginning of each function of interest, and one which is used at each exit point (the end of the function and just before each return statement) of that function.
If the code is sufficiently regular, you might want to develop a Perl script or something to modify the code for you, and then go through and clean up the modifications if necessary.--
Bill
Old age and treachery will overcome youth and skill.
- 07-17-2008 #5Just Joined!
- Join Date
- Dec 2007
- Posts
- 29
- 07-17-2008 #6
The only useful function you might not already use is gettimeofday(), which shows the time of day down to the microsecond. Remember, though, that although the precision is down to the microsecond, the accuracy is likely to be much less, maybe down to 10 milliseconds. But for gathering statistics on runtimes, you're not likely to need anything more accurate than that.
If your application is I/O bound and you're also interested in compute time, you might also want to use times(). In addition to providing compute time, it will also provide you with the amount of time elapsed since an arbitrary point in the past, which is useful if it's possible that you'll be running these tests while the system's time of day is being reset, either manually or because of change between standard time and daylight time. gettimeofday() would give you false elapsed time measurements in this case.--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote
