One, wall clock time, user CPU time, System CPU time definition and contact
Clock time (Wall clock time): The time that the clock passes from the start of the process to the end, which contains the time at which the process is blocking and waiting.
User CPU Time: Is the user's process to obtain the CPU resources after the user state execution time.
System CPU Time: The user process obtains CPU resources after the execution time in the kernel state.
the three states of the process are blocked, ready, and running.
clock time = blocking time + Ready time + run time
User CPU time = time of user space in the running state
System CPU Time = time of the system space in the running state.
User CPU time + system CPU time = Run time.
Attention:
Where user CPU time and system CPU time are the sum of CPU time, that is, the total amount of time the command consumes CPU execution. The actual time is greater than the CPU time, because Linux is a multitasking operating system, often when executing a command, the system also handles other tasks.
Another problem to be aware of is that even though the same command is executed every time, the time spent is not the same, and the time spent is related to the operation of the system.
On multicore processor machines, if a process contains multiple threads or creates child processes through a fork call, the actual time may be less than the total CPU time-because different threads or processes can execute in parallel, but their time accounts for the total CPU time of the master process. If the program is waiting for a certain period of time and is not executed, the actual time may be greater than the total CPU time. The numerical relationship is summarized as follows:
- Real < CPU, indicating that the process is computationally intensive (CPU bound), taking advantage of the parallel execution of multi-core processors;
- REAL≈CPU, indicating that the process is computationally intensive (CPU bound) and not executed in parallel;
- Real > CPU, which indicates that the process is I/o intensive (I/O bound), the multi-core parallel execution advantage is not obvious.
On a single-core processor, the difference between real time and CPU time, that is, real-(User + Sys), is the sum of all the factors that delay the execution of the program. The estimated CPU utilization during the run of the program is CPUUsage = (User + Sys)/Real * 100 (%).
On SMP (symmetric multi-processing systems), the difference is approximately real* processornum-(User + Sys). These factors include:
- I/O operation of the incoming program text and data;
- Get the I/O operation that the program actually uses memory;
- CPU time consumed by other programs;
- CPU time consumed by the operating system.
Second, examples
[Email protected]:~/temp$ time ./test sdga s d g a //above is the real of the test testing program 0m4.019s //clock time user 0m0.004s //user CPU time sys 0m0.000s //System CPU time
Iii. Reference Documents
Http://os.51cto.com/art/201407/445853.htm (said in detail, worth a look)
Http://blog.chinaunix.net/uid-27629574-id-3880991.html
http://blog.csdn.net/fjt19900921/article/details/8301230
Wall clock time, user CPU time, System CPU time