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. c
The First Command tells GCC to compile test. in C, the profile information is created for the prof command and the debugging information is added to the executable file. the second command only tells GCC to create profiling information for the
Grof IntroductionGprof is the GNU Profiler tool. You can display the "flat profile" of the program's operation, including the number of calls per function, and the processor time consumed by each function. You can also display the call graph, including the function's invocation relationship, and how long each function call takes. You can also display "source code for Comments", a copy of your program's source codes, and mark the number of times each line of code in your program is executed. Grof
Tool selectionHere's a reference to the http://gernotklingler.com/blog/gprof-valgrind-gperftools-evaluation-tools-application-level-cpu-profiling-linux/blog, It mainly analyzes the three Linux platform mainstream hot analysis tools, respectively, GNU Gprof, Valgrind and Google Perftools, the main features of the three tools are the following table:
Tools
Using commands
Whether you ne
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. c
The First Command tells GCC to compile test. in c, the profile information is cre
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 the characters with a gr
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 set of options. For example, the following two commands are different:Gcc-p-g test. c
Gcc-pg test. cThe First Command tells GCC to create profile information for the prof command during test. c compilation and add the debugging information to the executable file. The second command only tells GCC to create profiling informa
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 set of options. For example, the following two commands are different:
Gcc-p-g test. c
Gcc-pg test. c
The First Command tells GCC to create profile informatio
sound complicated, but it is not. The following is an example.
19 display_list {prcc. c 1056}20 show_all_lists {prcc. c 1070}21 exit {}22 main {prcc. c 70}23 show_all_lists {prcc. c 1070}24 usage {prcc. c 59}...74 printf {}75 display_list {prcc. c 1056}76 maketag {prcc. c 487}77 show_all_lists {prcc. c 1070}78 main {prcc. c 70}...99 usage {prcc. c 59}100 main {prcc. c 70}
For example, this tells us that the exit function has main, show_all_lists, and usage.
Use prof/
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. cGcc-PG test. cThe First Command tells GCC to compile test. in C, the profile information is created for the prof command and the debugging information is added to the executable file. the second command only tells GCC to create profiling information for the
complicated, but it's not actually the case. Here is an example.
display_list {PRCC.C 1056}show_all_lists {PRCC.C 1070}Exit {}Main {PRCC.C 70}show_all_lists {PRCC.C 1070}Usage {PRCC.C 59}...The "printf" {}display_list {PRCC.C 1056}Maketag {PRCC.C 487}show_all_lists {PRCC.C 1070}Main {PRCC.C 70}...Usage {PRCC.C 59}Main {PRCC.C 70}
For example, this tells us that the function to call exit has main,show_all_lists and usage.
Performing performance tests with Prof/
-party tools (for example, text Tools, string tools). It can be said that good business support and fool-type development are their main advantages.Under Linux, development tools are cut into separate gadgets. Each deal with a different problem. For example, the editor (Emacs, VIM) is used for editing programs, the debugger (GDB) is used to debug programs, the compiler (GCC) is used to compile and link programs, the Performance analysis tool (Gcov, gprof
separate gadgets. Each deal with a different problem. For example, the editor (Emacs, VIM) is used for editing programs, the debugger (GDB) is used to debug programs, the compiler (GCC) is used to compile and link programs, the Performance analysis tool (Gcov, gprof) is used to optimize the program, the document generator (Doxygen) is used to generate documents. At the same time, there are some system tools and system knowledge, we are very necessary
time.tree2dotx.Preparation
Several related tools need to be prepared in advance.
Gprof2dot: converts the output from your profilers into a dot graph$ sudo apt-get install python python-pip$ sudo pip install gprof2dot
Graphviz: dot format processing$ sudo apt-get install graphviz
Gprof: display call graph profile data$ sudo apt-get install gprof
Valgrind: a suite of tools for debugging and profiling pr
following line in the. gdbinit file:Define EfenceSet Environment Ef_protect_below 0Set Environment ld_preload/usr/lib/libefence.so.0.0echo Enabled Electric fence\nEndUsing Gprof for code coverageOne of the most common programming tasks is to improve code performance. To accomplish this task, be sure to find out which parts of the code spend the most time executing. In technical terms, this is called profiling. The GNU profiling tool
It's a shame to say so. have been using VIM to develop. But I don't know if VI has such a good tool. Used to always use:Find-type F-print | Xargs grep-i * * * * * in the source code to find.The original Linux also has a similar souce Insight tool. The following is an article referring to others. http://blog.chinaunix.net/u1/56619/showart_1822993.htmlComparison of Linux source code analysis and reading toolsThe source reading tool under Windows Souce Insight, with its ease of use and the support
, it also integrates the Debugger gdb, the performance analysis tool gcov, and gprof.
As long as GCC is installed, these powerful tools can be used directly. With gcov, we can view the number of times each line of code runs in the source code of a program. We can optimize the program by optimizing the code that runs the most frequently. When using gcov, You need to enable the fprofile-arcs and ftest-coverage options of GCC. Common options in gcov incl
/testmem/tmp)==4832====4832== HEAP SUMMARY:==4832== in with exit:0 bytes in 0 blocks==4832== Total Heap Usage:1 Allocs, 2 frees, Bytes allocated==4832====4832== all heap blocks were freed--no leaks is possible==4832====4832== for counts of detected and suppressed errors, rerun with:-V==4832== use--track-origins=yes to see where uninitialised values come from==4832== ERROR Summary:4 errors from 4 contexts (suppressed:11 from 6)Segmentation faultFrom the test output of valgrind, these errors have
very simple techniques, such as the loop-independent complex calculations or large memory operations of the code into the loop, for the overall performance improvement is really more obvious.
How to tune code using the code Profiler, which is the profiling tool.Program profiling (profiling) is actually inserting the tool code in a version of the running program to determine how much time is required for each part of the program.The UNIX system provides a profiling called
Http://www.cnblogs.com/me115/p/4605273.html
background
Developed a Redis data import tool using C + +Import all table data from Oracle into Redis;Not just data import, the original records in each Oracle, need to be processed by business logic,and add an index (Redis collection);When the tool is finished, performance is a bottleneck; optimization effect
2 Sample Data tests were used:Sample Data a table 8,763 records;Table B 940,279 Records;
Before optimization, a table is time-consuming 11.417s
file on the command line. The next section describes some of the options you will use most frequently.
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 the characters with a set of options. For example, th
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.