Time (Unix)
In computing, Overview
User time vs system timeThe total CPU time is the combination of the amount of time the CPU or CPUs spent performing some action for a program and the amount of time they spent performing system calls for the kernel on the program's behalf. When a program loops through an array, it is accumulating user CPU time. Conversely, when a program executes a system call such as Real time vs CPU timeThe term "real time" in this context refers to elapsed wall-clock time, like using a stop watch. The total CPU time (user time + sys time) may be more or less than that value. Because a program may spend some time waiting and not executing at all (whether in user mode or system mode) the real time may be greater than the total CPU time. Because a program may fork children whose CPU times (both user and sys) are added to the values reported by the UsageTo use the command, one simply precedes any command by the word $ time ls
When the command completes, $ time host wikipedia.org
wikipedia.org has address 103.102.166.224
wikipedia.org mail is handled by 50 mx2001.wikimedia.org.
wikipedia.org mail is handled by 10 mx1001.wikimedia.org.
host wikipedia.org 0.04s user 0.02s system 7% cpu 0.780 total
$
time (either a standalone program, or when Bash shell is running in POSIX mode AND time is invoked as time -pPortable scripts should use $ time -p sha256sum /bin/ls
12477deb0e25209768cbd79328f943a7ea8533ece70256cdea96fae0ae34d1cc /bin/ls
real 0.00
user 0.00
sys 0.00
$
ImplementationsGNU timeCurrent versions of GNU time, report more than just a time by default: $ /usr/bin/time sha256sum /bin/ls
12477deb0e25209768cbd79328f943a7ea8533ece70256cdea96fae0ae34d1cc /bin/ls
0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 2156maxresident)k
0inputs+0outputs (0major+96minor)pagefaults 0swaps
$
Format of the output for GNU time, can be adjusted using Documentation of this time can be usually accessed using Method of operationAccording to the source code of the GNU implementation of BashIn a popular Unix shell Bash, $ time seq 10000000 | wc -l
10000000
real 0m0.078s
user 0m0.116s
sys 0m0.029s
$
The reported time is a time used by both The time is not a builtin, but a special keyword, and can't be treated as a function or command. It also ignores pipeline redirections (even when executed as Documentation of this time can be accessed using See alsoThe Wikibook Guide to Unix has a page on the topic of: Commands
References
|
Portal di Ensiklopedia Dunia