Linux performance query command

Source: Internet
Author: User

(1) view the usage of each CPU Core

Sudo top-d 1

After entering, press 1, the following CPU usage will appear, the us column reflects the usage of each CPU core, the percentage is large, it indicates that the core is running a tight task.



(2) check which process is running on which CPU Core

Sudo top-d 1

After entering, press f, j, and space in turn, and the following will appear (the P column indicates the CPU core recently used by the process, such as the P column of the Process mencoder 7, it indicates that mencoder has recently run on Kernel 7. For multi-threaded or single-threaded processes, different CPU cores will be used at different times ):



(3) Check the overall CPU usage with vmstat

Sudo vmstat 2 3

Parameter 2 indicates that the result is displayed every 2 seconds, and 3 indicates the number of results.



The cs column indicates the number of context switches per second, and the us column indicates the user's CPU time.


(4) Intel tool powertop

Sudo powertop

The usage percentage of each CPU core is displayed.


(5) gprof analyzes a program

Assuming the program source file is speedup-example.cpp

Gcc speedup-example.cpp-o speedup-example-pg (note-pg)

Execute the program./speedup-example and generate gmon. out in the current directory. This file is the source for us to view the program running status. Then run the gprof command to view it:

Gprof-B speedup-example gmon. out> Results.txt

The running information of this program is in results.txt.



(6) pidstat displays the CPU usage and context switching of a process in real time.

First install

Sudo apt-get install sysstat

Next, use pidstat (the following-p is used with the process number to display the performance information of a specific process, and then you can specify the display every several seconds, a total of several items are displayed ):

  • Pidstat 5-p 15488 (pid of the process you want to track)

In this way, the CPU usage of the 15488 process can be displayed in Real Time:



  • Pidstat-w -- display context switching of each process
Pidstat-w-p 15488 2 -- display context switching of 15488 processes every 2 seconds:

Cswch/s -- the total number of voluntary context switches generated by the process per second. Voluntary context switches appears when accessing an occupied resource and thus has to be suspended (that is, we usually call Synchronization Context Switches)
Nvcswch/s -- total number of involuntary context switches generated by the process per second. Involuntary context switches occurs when the slice is used up or is preemptible by a higher priority (including Preemption Context Switches)


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.