Linux gprof Commands

Source: Internet
Author: User

First, Introduction

Gprof is one of the GNU tools, it is compiled at the time of the entry and exit of each function to add the profiling code, run-time statistics program in the user state execution information, you can get the number of calls per function, execution time, call relations and other information, easy to understand. It is suitable to find the performance bottleneck of the user-level program, and the gprof is not suitable for the program that is executed in kernel state many times.

Ii. methods of Use

1) Pass PG option to GNU Tools, both compiler and connector need to add-PG option

gcc -g-pg .......
2) Execute the program (note: Statistics files are generated only when the program terminates properly.) In other words, the program must be terminated from exit or return. )
file.
3) Analysis of generated results
Gprof [Options] < executables >

When you use Gprof to parse a gmon.out file, you need to associate it with the application that generated it:

Gprof <program> gmon.out--a Get a annotated "source code list" that will annotate the source and indicate the number of executions per function. This requires adding the-G option at compile time.

Reference: http://blog.chinaunix.net/uid-23767307-id-2940412.html

Linux gprof Commands

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.