aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2005-10-07 10:59:41 +0000
committerBruce Evans <bde@FreeBSD.org>2005-10-07 10:59:41 +0000
commit0b146898f0c76fed47af25c9df7719ce72d69e1e (patch)
tree59f0a66183febfd5642e7efa04be07f6a040d695 /usr.bin
parent8597a1c5b245b883fc86c0c88bafbacdacd1cf02 (diff)
downloadsrc-0b146898f0c76fed47af25c9df7719ce72d69e1e.tar.gz
src-0b146898f0c76fed47af25c9df7719ce72d69e1e.zip
Improve printing of self times in the flat profile for functions that
appear to be never called: (1) If a function is never called according to its call count but it must have been called because its child time is nonzero, then print it in the flat profile. Previously, if its call count was zero then we only printed it in the flat profile if its self time was nonzero. (2) If a function has a zero call count but has a nonzero self or child time, then print its total self time in the self time per call column as a percentage of the total (self + child) time. It is not possible to print the times per call in this case because the call count is zero. Previously, this was handled by leaving both per-call columns blank. The self time is printed in another column but there was no way to recover the total time. (1) partially fixes the case of the "never called" function main() and prepares for (2) to apply to main() and other functions. Profiling of main() was lost in the conversion from a.out to ELF, so main()'s call count has always been zero for many years; then in the common case where main() is a tiny function, it gets no profiling ticks, so main() was completely lost in the flat profile. (2) improves mainly cases like kernel threads. Most kernel threads appear to be never called because they are always started before userland can run to turn on profiling. As for main(), the fact that they are called is not very interesting and their callers are uninteresting, but their relative self time is interesting since they are long-running. Almost always printing percentages in the per-call columns would be more useful than almost always printing 0.0ms. 0.1ms is now a long time, so only very large functions take that long per call. The accuracy per call can approach 1-10 nsec provided programs are run for about 100000 times as long as is necessary to get this accuracy with high resolution kernel profiling.
Notes
Notes: svn path=/head/; revision=151055
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/gprof/printgprof.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/gprof/printgprof.c b/usr.bin/gprof/printgprof.c
index 4ca539588c73..41c1c1f5c255 100644
--- a/usr.bin/gprof/printgprof.c
+++ b/usr.bin/gprof/printgprof.c
@@ -130,7 +130,8 @@ flatprofline( np )
register nltype *np;
{
- if ( zflag == 0 && np -> ncall == 0 && np -> time == 0 ) {
+ if ( zflag == 0 && np -> ncall == 0 && np -> time == 0 &&
+ np -> childtime == 0 ) {
return;
}
actime += np -> time;
@@ -153,6 +154,9 @@ flatprofline( np )
printf( " %8ld %8.2f %8.2f " , np -> ncall ,
1000 * np -> time / hz / np -> ncall ,
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
+ } else if ( np -> time != 0 || np -> childtime != 0 ) {
+ printf( " %8ld %7.2f%% %8.8s " , np -> ncall ,
+ 100 * np -> time / ( np -> time + np -> childtime ) , "" );
} else {
printf( " %8.8s %8.8s %8.8s " , "" , "" , "" );
}