Gprof is a program time monitoring tool provided by GNU and is a component of the binutils. It can count the run time of the function.
Gprof must be used in conjunction with GCC. That is, a program compiled with the-PG option specified in GCC is sufficient to use GPROF statistics. After compiling the executable file, run the file first, which generates the Gmon.o
Address: http://sam.zoy.org/writings/programming/gprof.html
Howto: Using
gprofWith Multithreaded Applications what is
gprof?
gprofIs the GNU profiler, a tool used when tracking which funich are eating CPU in your program. Anyway, you shoshould already be familiar with it if you got interested in this page.
One problemgprofUnder certain kernels (such as Linux) is that it doesn' t behave correctly with Multithreaded Applications. It actually only profil
GPROF is used to know that GPROF can only count the time consumed by the main thread. No thread-related issues on manual?
But there is a ready-made solution: http://sam.zoy.org/writings/programming/gprof.html
This solution encapsulates pthread_create () and enables the thread to initialize and execute a setitimer (itimer_prof ,...).
The simple method is to directlyCodeWrite a setitimer ().
# Include
When you use the gprof, you only know that the original gprof can only be counted on the main thread. There are no thread-related issues on the manual.
But there are ready-made solutions: http://sam.zoy.org/writings/programming/gprof.html
The scheme encapsulates the pthread_create (), allowing the thread to initialize the execution of a setitimer (Itimer_prof, ...).
An easy way to do this is to write a s
1. Use vim and ctags/cs.pdf.
In Linux, we provide a complete IDE and VIM Quick Start-run vimtutor directly to familiarize yourself with vim commands according to the training requirements.
Ctags/csags to helpProgramBrowsing the program.
Http://easwy.com/blog/archives/vim-cscope-ctags/
2. GDB tool.
This isCodeThe debug tool has the same functions as the debug tool provided by.
Quick Start:
Http://www.huihoo.org/gnu/linux/gdb.html
Http://www.cs.cmu.edu /~ Gilpin/tutorial/
3
First, the preface
Reference gprof User manual: Http://sourceware.org/binutils/docs-2.17/gprof/index.html
Reference Blog: http://blog.csdn.net/stanjiang2010/article/details/5655143
Gprof is GCC's own performance testing tool, which can count the number of calls, time, and function call graphs for each function.
Second, the tutorial
Using GRPOF is divided into thr
(1) View the usage of each CPU coresudo top-d 1After entering, press 1, the following CPU usage will appear, in which the US column reflects the use of each CPU core, the percentage of large indicates that the core in the task of intense.(2) See which process is executing on which CPU coresudo top-d 1After entering, by pressing F, j, and spaces, for example the following (P column indicates that the process is recently used by the CPU core, such as process mencoder P column 7, it means mencoder
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. The following describes a Program Profiling tool in Linux-GNU profiler.
Basic usage of gprof:
1. Use the-pg option to compi
performance measurements let you know that the Code consumes most of the time. The performance measurement tool can measure the number of times a function is called, and the number of times a row of code or logic Branch runs. The call graph of the called function and the time consumed by each part of the program. GPROF is a standard GNU performance measurement tool that also requires GCC.Coverage measurement: Why is it so troublesome?Although coverag
specified by the command line option will be executed on each given file on the command line. The next section describes the options you will most commonly use.
GCC options
GCC has more than 100 compilation options available. many of these options may never be used, but some of the main options will be frequently used. many GCC options include more than one character. therefore, you must specify the respective characters for each option, and, just like most Linux commands, you cannot separate
Performance Optimization practices of C ++Contents of C ++ performance optimization practices:
1 Gprof
2. gprof usage steps
1. Time consumed for initializing large objects
2. Improper Map use
Optimization criteria:
1. the 20% rule: in any group of things, the most important part is only a small part, about 80%, and the other, although the majority, is secondary. In optimization practices, we will focus
some of the options that you will most commonly use.
GCC Options
GCC has more than 100 compilation options available. Many of these options may never be used, but some of the major options will be used frequently. Many of the GCC options include more than one character.So you have to specify individual hyphens for each option, and just like most Linux commands you can't have a single hyphen followed by a set of options. For example, the following two commands are different:Gcc-p-G test.c
GCC-PG
GNU binutils is a set of binary tools. Including addr2line ar GPROF nm objcopy objdump ranlib size strings strip. This article summarizes their common methods.Ar
Ar is used to create, modify, and extract archive files ). Archive is a single file (also called a library file) that contains multiple files. Its structure ensures that the original contained files (called member in archive) can be retrieved and obtained ). Attributes such as the content, m
GNU binutils is a set of binary tools. Including addr2line ar GPROF nm objcopy objdump ranlib size strings strip. This article summarizes their common methods. Ar --------------------------------------------------------------------------------
Ar is used to create, modify, and extract archive files ). Archive is a single file (also called a library file) that contains multiple files. Its structure ensures that files can be retrieved from it.
And get t
optionsGCC has more than 100 compilation options available. many of these options may never be used, but some of the main options will be frequently used. many GCC options include more than one character. therefore, you must specify the respective characters for each option, and, just like most Linux commands, you cannot separate the characters with a group of options. for example, the following two commands are different:
Gcc-p-g test. c
Gcc-PG test. cThe First Command tells GCC to compile tes
Optimization criteria:1.28 rule: In any group of things, the most important is only a small part, about 20%, the remaining 80%, although the majority, but is secondary; in optimization practice, we focus on optimizing the 20% most time-consuming code, the overall performance will be significantly improved; This is a good understanding. function A, although a large amount of code, is called only once in a normal execution process. Another function, B, has a much smaller code than a, but is called
Optimization criteria:
1. the 20% rule: in any group of things, the most important part is only a small part, about 80%, and the other, although the majority, is secondary. In optimization practices, we will focus on optimizing the 20% most time-consumingCode, The overall performance will be significantly improved; this is a good understanding. Although function A has a large amount of code, it calls only once in a normal execution process. Another function, B, has much less code than a, but
. many of these options may never be used, but some of the main options will be frequently used. many GCC options include more than one character. therefore, you must specify the respective characters for each option, and, just like most Linux commands, you cannot separate the characters with a group of options. for example, the following two commands are different:Gcc-p-g test. c
Gcc-PG test. cThe First Command tells GCC to compile test. in C, the profile information is created for the prof co
Performance Optimization GPROF, a program performance analysis tool in Linux
GPROF is installed in the/usr/bin directory of Linux. It analyzes your program and determines which part of the program is the most time-consuming.
GPROF will tell you the number of calls to each function in the program and the percentage of time each function is executed. This informati
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.