$ time foo
real 0m0.003s
user 0m0.000s
sys 0m0.004s
$
What do \'real\', \'user\' and \'sys\' mean in the output of time?
In very simple terms, I like to think about it like this:
real
is the actual amount of time it took to run the command (as if you had timed it with a stopwatch)
user
and sys
are how much 'work' the CPU
had to do to execute the command. This 'work' is expressed in units of time.
Generally speaking:
user
is how much work the CPU
did to run to run the command's codesys
is how much work the CPU
had to do to handle 'system overhead' type tasks (such as allocating memory, file I/O, ect.) in order to support the running commandSince these last two times are counting 'work' done, they don't include time a thread might have spent waiting (such as waiting on another process or for disk I/O to finish).
real
, however, is a measure of actual runtime and not 'work', so it does include any time spent waiting.