GPROF-performance optimization tool for programs in Linux

Source: Internet
Author: User

 

When writing programs, especially embedded programs, we usually need to analyze the program's performance so that the program can run faster and better to achieve real-time. If the program is large, it will be difficult to analyze it. If there is a tool that can automatically analyze the program's performance, it would be better. Here is a profiling tool for Linux programs ---

Gnu gprof.

Gnu gprof can print the time consumed by each function in the program running, and help programmers find the most time-consuming function among many functions. Generate the function call relationship when the program is running, including the number of calls, which can help the programmer analyze the program running process. With the function call relationship, developers can greatly improve their work efficiency and do not bother to find out the running process of the program. This may not be very effective for small programs, however, for projects with tens of thousands or hundreds of thousands of codes, efficiency is beyond doubt! In addition, this function is quite attractive for maintaining the old code or analyzing open source. With the call diagram, we also have a general understanding of the program running framework, knowing the "skeleton" of the program, analyzing it will not be so confused, especially for yourself
Familiar code and open source.

Basic usage of GPROF:
1. Use the-PG option to compile and link your application

When compiling a program with GCC, add the-PG option, for example:
Gcc-PG-O test. c
In this way, the executable file test is generated. If it is a large project, modify the compilation option in makefile, where-PG can be put.

2. Execute your application to generate data for GPROF Analysis

Run the program:./test. A gmon. Out file is generated, which contains the profiling data.

3. Use GPROF to analyze the data generated by your application

GPROF test gmon. Out> profile.txt
With the authorization command, gprofcan be used to store the profilingresult in the profile.txt file, and the analysis result is displayed. Through the analysis of the results to improve our procedures, so as to achieve our goal.

Gnu gprof is a good tool that can be used for programming. I now use GPROF to profiling my program, find out the most time-consuming functions or operations, and use an FPGA chip to achieve real-time.

 

Http://hi.baidu.com/jedora/blog/item/e1b7cffc59f7eb86b801a012.html

Http://hujw0710.blog.163.com/blog/static/8797282200952324755785/

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.