The time
you use in your question is not a command, but rather a reserved word in zsh. It can be used in two different ways and its output can be customized through the $TIMEFMT
parameter. There is also an external command time on macOS, which produces slightly different output.
Just time
time
by itself (as shown in your question) will report time statistics for the current shell:
shell
is the current shell from which you executed yourtime
statement.children
is a summary of all running processes started from (and still owned by) that shell.user
andsystem
show the amount of CPU seconds the above processes spent in user mode and kernel mode, respectively. See https://blog.codinghorror.com/understanding-user-and-kernel-mode/ for more info.cpu
shows the combined values ofuser
andsystem
, as a percentage of total CPU time.total
shows how long ago the shell or its oldest child process was started (here in minutes:seconds.fraction).
time <command>
More often, time
is added before a command. If you use it that way, then the shell will report time statistics only for that command:
% time sleep 0
sleep 0 0.00s user 0.00s system 43% cpu 0.007 total
%
total
here is the number of seconds it took for the command to complete.
Customizing time
output
time
's output can be customized by setting the $TIMEFMT
parameter. For example:
% TIMEFMT='%J %U user %S system %P cpu %*E total %M max RSS'
% time
shell 39.79s user 72.26s system 0% cpu 84:33:14.91 total 25848 max RSS
children 1089.58s user 919.02s system 0% cpu 84:33:14.91 total 52528 max RSS
% time sleep 0
sleep 0 0.00s user 0.00s system 61% cpu 0.003 total 580 max RSS
%
External Command time
The external command time
can be used as follows:
% command time
% command time sleep 0
0.00 real 0.00 user 0.00 sys
% command time -p sleep 0
real 0.00
user 0.00
sys 0.00
% command time -l sleep 0 # Prints memory usage
0.00 real 0.00 user 0.00 sys
585728 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
160 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
0 voluntary context switches
1 involuntary context switches
2198249 instructions retired
3195521 cycles elapsed
237568 peak memory footprint
%
real
here is the same as total
, above.