gprof | Début | Suivant | Sommaire | Préc.page.lue | Accueil |
NAME | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
SYNOPSIS | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
DESCRIPTION | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
"Gprof" calculates the amount of time spent in each routine. Next, these times are propagated along the edges of the call graph. Cycles are discovered, and calls into a cycle are made to share the time of the cycle.
Several forms of output are available from the analysis.
The flat profile shows how much time your program spent in each function, and how many times that function was called. If you simply want to know which functions burn most of the cycles, it is stated concisely here.
The call graph shows, for each function, which functions called it, which other functions it called, and how many times. There is also an estimate of how much time was spent in the subroutines of each function. This can suggest places where you might try to eliminate function calls that use a lot of time.
The annotated source listing is a copy of the program's source code, labeled with the number of times each line of the program was executed.
OPTIONS | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
Many of these options take an optional symspec to specify functions to be included or excluded. These options can be specified multiple times, with different symspecs, to include or exclude sets of symbols.
Specifying any of these options overrides the default (-p -q), which prints a flat profile and call graph analysis for all functions.
If the profile data file contains basic-block count records, specifying the -l option, along with -C, will cause basic-block execution counts to be tallied and displayed.
The exact details of how to force the linker to place functions in a particular order is system dependent and out of the scope of this manual.
Use of the -a argument is highly recommended with this option.
The map_file argument is a pathname to a file which provides function name to object file mappings. The format of the file is similar to the output of the program "nm".
c-parse.o:00000000 T yyparse c-parse.o:00000004 C yyerrflag c-lang.o:00000000 T maybe_objc_method_name c-lang.o:00000000 T print_lang_statistics c-lang.o:00000000 T recognize_objc_keyword c-decl.o:00000000 T print_lang_identifier c-decl.o:00000000 T print_lang_type ...
To create a map_file with GNU "nm", type a command like "nm --extern-only --defined-only -v --print-file-name program-name".
Analysis Options | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
If the program was compiled with basic-block counting enabled, this option will also identify how many times each line of code was executed. While line-by-line profiling can help isolate where in a large function a program is spending its time, it also significantly increases the running time of "gprof", and magnifies statistical inaccuracies.
Miscellaneous Options | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
Eventually you can run "gprof" again without -s to analyze the cumulative data in the file gmon.sum.
Deprecated Options | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
"-e function_name"
The -e function option tells "gprof" to not print information about the function function_name (and its children...) in the call graph. The function will still be listed as a child of any functions that call it, but its index number will be shown as [not printed]. More than one -e option may be given; only one function_name may be indicated with each -e option.
"-E function_name"
The "-E function" option works like the "-e" option, but time spent in the function (and children who were not called from anywhere else), will not be used to compute the percentages-of-time for the call graph. More than one -E option may be given; only one function_name may be indicated with each -E option.
"-f function_name"
The -f function option causes "gprof" to limit the call graph to the function function_name and its children (and their children...). More than one -f option may be given; only one function_name may be indicated with each -f option.
"-F function_name"
The -F function option works like the "-f" option, but only time spent in the function and its children (and their children...) will be used to determine total-time and percentages-of-time for the call graph. More than one -F option may be given; only one function_name may be indicated with each -F option. The -F option overrides the -E option.
FILES | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
BUGS | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
Parents that are not themselves profiled will have the time of their profiled children propagated to them, but they will appear to be spontaneously invoked in the call graph listing, and will not have their time propagated further. Similarly, signal catchers, even though profiled, will appear to be spontaneous (although for more obscure reasons). Any profiled children of signal catchers should have their times propagated properly, unless the signal catcher was invoked during the execution of the profiling routine, in which case all is lost.
The profiled program must call "exit"(2) or return normally for the profiling information to be saved in the gmon.out file.
SEE ALSO | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
``An Execution Profiler for Modular Programs'', by S. Graham, P. Kessler, M. McKusick; Software - Practice and Experience, Vol. 13, pp. 671-685, 1983.
``gprof: A Call Graph Execution Profiler'', by S. Graham, P. Kessler, M. McKusick; Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, SIGPLAN Notices, Vol. 17, No 6, pp. 120-126, June 1982.
COPYRIGHT | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''.
POD ERRORS | Début | Précédent | Suivant | Sommaire | Préc.page.lue | Accueil |
Sommaire | Début | Suivant | Sommaire | Préc.page.lue | Accueil |