Use of grof-Performance Testing Tool

Source: Internet
Author: User
GPROF Introduction
GPROF is the GNU profiler tool. The "flat"
Profile, including the number of calls to each function and the processor time consumed by each function. You can also display the "Call diagram", including the call relationship of the function, and the time consumed by each function call. You can also display the "annotated source code", which is a copy of the program source code, marking the number of executions of each line of code in the program.

Compile a program for GPROF
When compiling or linking the source program, add the "-PG" option to the compiler's command line parameters. during compilation, the compiler automatically inserts a code snippet for performance testing in the target code, these codes collect and record the call relationship and number of calls of the function when the program is running, and collect and record the execution time of the function and the call time of the sub-function. After the program runs, A gmon is generated in the exit path of the program. out file. This file is the monitoring data recorded and saved. You can use GPROF in command line mode or kprof in graphical mode to interpret the data and analyze the program performance. In addition, if you want to view the profiling of the library function, you need to add "-lc_p" to compile the parameter in place of "-LC". In this way, the program will link to library libc_p.a, to generate the profiling information of the library function. If you want to execute the profiling of one row and one row, you also need to add the "-G" Compilation parameter.
For example, the following command line:
Gcc-wall-g-PG-lc_p example. C-o example

Execute GPROF
Run the following command to execute GPROF:
GPROF
Options executable-file gmon. Out BB-DATA [yet-more-profile-data-files...] [>
OUTFILE]

Information generated by GPROF
% The percentage
The total running time of
Time program used by this
Function.
The percentage of time used by the function to all time.
Cumulative
A running sum of the number of seconds accounted
Seconds for
This function and those listed abve it.

Cumulative execution time of functions and upper-column functions.
Self the number of seconds accounted
By this
Seconds function alone. This is the major sort
This
Listing.

The time when the function is executed.
Callthe number of times this function was
Invoked, if
This function is profiled, else
Blank.
Number of function calls
Self
Average number of milliseconds spent in this
MS/call Function
Per call, if this function is profiled,
Else
Blank.

Each call takes microseconds as the function time.
Total the average number
Milliseconds spent in this
MS/call Function and Its descendents
Per call, if this
Function is profiled, else
Blank.

The average time of each call is microseconds.
Name the name of
Function. This is the minor sort
For this listing.
The index shows the location
The function in
GPROF listing. If the index is
In parenthesis it
Shows where it wowould appear in
The GPROF listing if
It were to be printed.

Function Name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.