Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What specifically are wall-clock-time, user-cpu-time, and system-cpu-time in UNIX?

Wall-clock time is the time that a clock on the wall (or a stopwatch in hand) would measure as having elapsed between the start of the process and 'now'.

The user-cpu time and system-cpu time are pretty much as you said - the amount of time spent in user code and the amount of time spent in kernel code.

The units are seconds (and subseconds, which might be microseconds or nanoseconds).

The wall-clock time is not the number of seconds that the process has spent on the CPU; it is the elapsed time, including time spent waiting for its turn on the CPU (while other processes get to run).


Wall clock time: time elapsed according to the computer's internal clock, which should match time in the outside world. This has nothing to do with CPU usage; it's given for reference.

User CPU time and system time: exactly what you think. System calls, which include I/O calls such as read, write, etc. are executed by jumping into kernel code and executing that.

If wall clock time < CPU time, then you're executing a program in parallel. If wall clock time > CPU time, you're waiting for disk, network or other devices.

All are measured in seconds, per the SI.


time [WHAT-EVER-COMMAND]

real    7m2.444s
user    76m14.607s
sys 2m29.432s

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                24

real or wall-clock

real 7m2.444s

On a system with 24 core processor, this cmd/process took 7+ mins to complete. That by utilizing the most possible parallelism with all given cores.

user

user 76m14.607s

The cmd/process has utilized this much amount of cpu time. In other words, on machine with single core CPU, the real and user will be nearly equal, so the same command will take ~76 mins to complete.

sys

sys 2m29.432s

This is the time taken by the kernel to execute all the basic/system level operations to run this cmd, including context switching, resource allocation, etc.

Note: The example assumes that your command utilizes parallelism/threads.

Detailed man page: https://linux.die.net/man/1/time


Wall clock time is exactly what it says, the time elapsed as measured by the clock on your wall (or wristwatch)

User cpu time is the time spent in "user land", that is time spent on non-kernel processes

System cpu time is time spent in the kernel, usually time spent servicing system calls.