This is what I got from the terminal command "time".
shell 0.32s user 0.08s system 0% cpu 6:09.64 total
children 0.10s user 0.16s system 0% cpu 6:09.64 total
What is children?
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. Additionally, there is an external command time
on macOS (and most other Unix-like OSes), which produces slightly different output.
time
If you use time
by itself (as shown in your question), then your current shell will report time statistics for itself and its children:
shell
represents the shell in which you executed your time
statement. children
is a summary of all running processes started from (and still owned by) that shell.user
and system
show the amount of CPU seconds the above processes spent in user mode and kernel mode, respectively.cpu
shows the combined values of user
and system
, 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 for that command only:
% 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.
time
outputtime
's output can be customized by setting the $TIMEFMT
parameter. For example, we can add memory usage:
% TIMEFMT+=' max RSS %M'
% time
shell 0.22s user 0.10s system 53% cpu 0.601 total max RSS 6120
children 0.11s user 0.16s system 45% cpu 0.601 total max RSS 3056
% time sleep 0
sleep 0 0.00s user 0.00s system 61% cpu 0.003 total max RSS 580
%
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 # Show 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.
time python x.py -h
, which didn't return the real time, but as suggested here, command time python x.py -h
works as the unix time utility in the zsh shell.
Commented
Apr 5, 2023 at 12:24
time
is an internal zsh command, and not reastricted to an internactive zsh, I think you can remove the other 3 tags from your question.