开发者

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

I can take a guess based on the names, but what specifically are wall-clock-time, user-cpu-time, and system-cpu-time in Unix?

Is user-cpu time the amount of time spent executing user-code while kernel-cpu time the amount of time spent in the kernel due to th开发者_开发技巧e need of privileged operations (like I/O to disk)?

What unit of time is this measurement in?

And is wall-clock time really the number of seconds the process has spent on the CPU or is the name just misleading?


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 a 24 core-processor, this cmd/process took more than 7 minutes 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 approximately 76 minutes 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜