Testing, debugging, and performance testing tools available in linux

Source: Internet
Author: User
The testing, debugging, and performance testing tools that are readily available in linux are originally named test, debugging, and performance tools that come with linux, but they are not appropriate. for example, gdb mentioned in this article, many Linux distributions provide it, but after all it is not a necessary part of Linux, just for most Lin... the tool for testing, debugging, and performance testing that is readily available in linux is originally titled "testing, debugging, and performance tools of linux", but it is not appropriate, such as gdb mentioned in this article, many Linux distributions provide it, but it is not a necessary part of Linux, but it is readily available to most Linux users. Reasonable combination of these tools can meet more complex requirements and write test scripts, which can provide great convenience for testing. This article does not involve writing specific scripts or network-related commands such as netstat and tcpdump. To facilitate reading, use a horizontal line to split the content and prompt the content under each underline. For ~ 6 these commands seem simple to be used separately, but they can exert their real power only when combined with redirection and regular expressions to form more complex functions or even automated scripts. Cmp and diff can be used for version control and compare the differences between two version files. They can also be used to compare program output. 1. cmp compares two files by byte and outputs them. If there is no option, the first difference is output. Common options:-l outputs all different bytes and displays the number of bytes (in decimal format) and each different byte (in octal format ). For example, if file1.txt is Octal to 151,flie2.txt and 12, the system displays: 3 151 12 2. diff compares two files row by row. if the directory is specified, the system compares the files with the same name in the directory. The output is: number of lines in file 1 + format prompt + number of lines in file 2, where the format prompt is a, c, d, corresponding to add, change, delete. The exit value of diff has a specific meaning. 0 indicates no difference, 1 indicates finding different places, and 2 indicates an error. Common options:-y -- side-by-side are output in two columns. Use | to mark different rows of the two, <标注后者比前者少一行,> The former is less than the latter. You can also add the following options:-w num -- width = NUM to output a maximum of NUM (130 by default) columns. -- Left-column: only the left column of the total row is output. -C-c num -- context [= NUM]: output the context of NUM (default: 3) row replication. The full text of both files is displayed. -U-u num -- uniied [= NUM]: output the context of NUM (default 3) row merging. The same parts of the two files are only displayed once. -RuN generates a patch file in the format of diff-ruN file1 file2> patch. dat. then, you can use patch file1 patch. dat to update the content of file1 to be consistent with that of file2. Sort, sum, and wc can also process files and outputs as needed. For Linux, which can redirect stdin to a file, the output processing is the same as the file processing. 3. sort outputs rows in alphabetical order. This command can process multiple files at the same time. Common options:-u remove duplicate rows-r output in descending order-n sort by number (so that 2 won't be ranked after 10)-t separate by a separator, in this case, you can use-k to specify the number of columns 4.sum to calculate the file checksum and the number of blocks occupied. The size of the checksum algorithm and block can be set according to the options. 5. number of lines of wc output files, number of words, and number of bytes. If there is more than one file, the total number of lines will be output. Common options:-c number of output bytes-m Number of output characters-l number of output lines-w number of output words (word) 6. grep searches for content conforming to the regular expression in the text and displays it. Here we will not mention how powerful the regular expression is. its rules can be written into a blog article separately, and many people have already done so. The following are some usage inspirations. after reading this article, we will feel that the original "search" needs are so diverse. The example is out of "program design practice": which files use the Regexp class? % Grep Regexp *. which file does the java class implement? % Grep 'class. * Regexp '*. how many blank lines does the java file contain? % Grep '. '*. c ++ | wc running time statistics and determination: time and gprof 7. the time usage is $ time. the executable file/Command shows the total time, user time, and system time of the program running. For a program with short execution time, the running time may be displayed as 0. Because it is not collected by the program execution itself. if the time command is stopped or switched out of memory, the displayed time may be greater than the actual time. 8. gprof calculates the running time and number of calls of each function during the running of the program. This is very helpful for code optimization. through this statistics, you can find functions with a large time-consuming ratio and a large number of calls and perform alignment optimization to improve program performance. For functions with less execution and less time consumption, even if there is a possibility of optimization, you do not have to worry about the optimization scheme, because the optimization of it does not significantly improve the performance. If you need gprof, you need to add the-pg option during gcc. a gmon. out file is generated. Code error: the gcc-Wall option and lint9.gcc-Wall columns this gcc option, mainly because it is easy to be ignored. The difference between investors and gamblers is that investors take advantage of every opportunity, no matter how small it is, while gamblers rely only on luck. The author suggests applying this sentence to programming, selecting all the optional warning options for the compilation program, and regard it as a program investment with no risk and high repayment. Do not ask "should I use this warning facility ?" "Why not use this warning facility ?" Enable all warning options unless there is an excellent reason for not doing so. 10. lint was initially used to check unportable code in C language, but now it is not just a portability check program, you can also check out the features in the code that are portable and fully compliant with the syntax but are likely to be incorrect. Lint has many versions. in Linux, splint can be used for installation through apt-get. Comprehensive debugging: gdb11.gdb is a comprehensive debugging tool that provides functions such as breakpoint, variable monitoring and setting, signal, function stack viewing, and single-step execution, I will not describe it in detail here. There are many related blog posts for reference. I have also made a record before: gdb debugging command. Others: strace12.strace strace can trace the system calls generated by a process, including parameters, return values, and execution time.

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.