[One Linux Command every day] 08. usage of the Time Command in Linux

Source: Internet
Author: User


In Linux, the time command is often used to calculateProgramRunning time (real), user-mode CPU time (user), and system-mode CPU time (sys)


The most common use of time commands is to follow the commands and parameters directly after them:
Time <command> [<arguments...>]

Example 1:

 
Bixiaopeng @ bixiaopengtekimacbook-pro ~ $ Time sleep 2 Real 0m2. 005 suser 0m0. 001 SSYS 0m0. 002 s

Slight explanation:

Real 0m2. 005 S: sleep the program runs for 0m2. 005 s
User 0m0. 001 S:This time indicates the CPU time when sleep runs in the user State.
Sys 0m0. 002 s: This time indicates the CPU time when sleep runs in the core state.

User Mode ):

In user mode,CodeWithout the ability to directly access the hardware or access the memory, you must use the reliable and underlying APIs provided by the operating system to access the hardware or memory. Due to the protection function of this isolation, the user-mode code crashes (crash) and the system can be restored. Most of our code runs in user mode.

Kernel Mode):
In the kernel mode, the Code has the ability to access the underlying hardware without any restrictions. Attackers can execute arbitrary CPU commands to access any memory address. The kernel mode is generally run for the underlying, trusted, and reliable Code provided by the operating system. The kernel-State Code crash will be disastrous, and it will affect the entire system.

Why distinguish between kernel mode and user mode?:
Isolate protection to make the system more stable.
Well, after talking about the user State and core State, let's look at the user time. As we said, this refers to the CPU time when the program Foo runs in the user State, the CPU time is not the time that the clock goes by on the wall, but the CPU working time.

Example 2:

# Time-P does not show unit bixiaopeng @ bixiaopengtekimacbook-pro ~ $ Time-P sleep 2 Real 2.00 user 0.00sys 0.00


Related Article

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.