Detailed explanation of the use of Linux time command

Detailed explanation of the use of Linux time command

1. Command Introduction

time is used to count the time consumed by command execution and related system resources and other information. There are four major resources that time can display, namely:

Time resources
Memory resources
IO resources
Command info

2. Command format

time [options] command [arguments...]

3. Option Description

-f FORMAT, --format=FORMAT: Output using the specified format. If the output format is not specified, the format specified by the environment variable TIME is used. -p, --portability: Use a compatible output format, real %e user %U sys %S. The purpose of this is to be compatible with the POSIX specification. -o FILE, --output=FILE: Set the result output file. This option will write the output of time to the specified file. If the file already exists, overwrite its contents -a, --append: Used with the -o option, use append mode to write the output to the specified file -v, --verbose: Use verbose mode to output statistics as much as possible --help: Display help information -V, --version: Display version information -- : Terminate the option list

The output format is interpreted in a similar way to printf. Ordinary characters are output directly. Tabs, newlines, backslashes, and percent signs are represented by \t, \n, \, and %% respectively. % followed by other letters indicates a special format. The available formats are as follows:

Time
%E: The time it takes to execute the command, in the format [hours:]minutes:seconds
%e: The time it takes to execute the instruction, in seconds %S: The time it takes in kernel mode when the instruction is executed, in seconds %U: The time it takes in user mode when the instruction is executed, in seconds %P: The percentage of CPU usage when executing the instruction. In fact, this number is the CPU time in kernel mode plus user mode divided by the total time ((%S+%U)/%E)

Memory
%M: The maximum amount of memory used during execution. Unit: KB
%t: The average memory usage during execution, in KB
%K: The average size of the total memory (stack+data+text) used by the executed program, in KB
%D: The average size of the unshared data area of ​​the executing program, in KB
%p: The average size of the unshared stack of the executing program, in KB
%X: The average value of the shared text segment of the executing program, in KB
%Z: The size of the system memory page, in bytes. This is a constant for the same system %F: Number of memory page faults. Memory page faults refer to the need to read data from disk into memory %R: The number of minor or recoverable page faults. These are faults for invalid pages, but that memory page is not yet in use by other virtual pages. Therefore, the data in the page is still valid, but the system table must be updated %W: The number of times the process has been swapped out of memory %c: The number of times the process context has been switched (because the time slice has expired)
%w: The number of times the process waits, which refers to the number of times the program actively switches contexts, such as waiting for an I/O operation to complete.
%I: The number of files input by this program %O: The number of files output by this program %r: The number of Socket Messages received by this program
%s: Socket Message sent by this program
%k: The number of signals received by this program Command Info
%C: Parameters and command name during execution %x: Exit Status of the command

4. Common Examples

(1) Statistics on the execution time of the specified command.

time date 
Fri May 31 11:30:04 CST 2019

real 0m0.001s
user 0m0.000s
sys 0m0.000s

The above is the detailed content of the use of Linux time command. For more information about Linux time command, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed Tutorial on Using xargs Command on Linux
  • Use of Linux tr command
  • Use of Linux ipcs command
  • Linux sar command usage and code example analysis
  • Use of Linux ls command
  • Use of Linux sed command
  • Use of Linux read command
  • Use of Linux usermod command
  • Use of Linux passwd command
  • Use of Linux ln command
  • Use of Linux telnet command

<<:  Some "pitfalls" of MySQL database upgrade

>>:  How to implement draggable components in Vue

Recommend

Detailed explanation of the process of using GPU in Docker

Table of contents Download tf-gpu Build your own ...

Detailed explanation of nginx request header data reading process

In the previous article, we explained how nginx r...

Solution to the error problem of Vscode remotely connecting to Ubuntu

1. Background of the incident: Because of work ne...

Use Firebug tool to debug the page on iPad

How to debug a page on iPad? When using iOS 5, you...

Enable sshd operation in docker

First, install openssh-server in docker. After th...

17 excellent web designs carefully crafted by startups

Startups often bring us surprises with their unco...

In-depth explanation of iterators in ECMAScript

Table of contents Preface Earlier iterations Iter...

MySQL SQL statement analysis and query optimization detailed explanation

How to obtain SQL statements with performance iss...

Use of nginx custom variables and built-in predefined variables

Overview Nginx can use variables to simplify conf...

How to deploy FastDFS in Docker

Install fastdfs on Docker Mount directory -v /e/f...

How to manage cached pages in Vue

Table of contents Problem 1: Destruction 1. How t...

Axios project with 77.9K GitHub repository: What are the things worth learning?

Table of contents Preface 1. Introduction to Axio...

CenterOS7 installation and configuration environment jdk1.8 tutorial

1. Uninstall the JDK that comes with centeros fir...

Review of the best web design works in 2012 [Part 1]

At the beginning of the new year, I would like to...