What is CPU Time and Elapsed Time?
CPU time/Process time is the amount of time CPU spends processing instructions of a program.
This time doesnt include waiting for input/output operations.
The CPU time is often measured in clock ticks or as a percentage of the CPU capacity.
It is used as a measure of CPU usage by a program.
In contrast, Elapsed real time/real time/wall clock time is the time taken from the start of a computer program until the end as measured by an ordinary clock.
Elapsed real time includes I/O time and all other types of waits incurred by the program.
Total CPU time:
On multi-processor machines, a computer program can use two or more CPUs for processing using parallel processing scheduling.
In such situations, the term Total CPU time is used, which is the sum of CPU time consumed by all of the CPUs with respect to the computer program.
CPU time and Elapsed real time:Which is greater?
Elapsed real time is always same or more than CPU time for computer program which use only one CPU for processing.
If no wait is involved for I/O or other resources, Elapsed real time and CPU time should be almost same.
CPU time and elapsed real time for parallel processing technology:
As inidicated before CPU time cannot be greater than Elapsed time;but Total CPU Time can be!
Total CPU time for computer program which uses parallel processing technology could be more than Elapsed real time.
Elapsed real time in this case is (Total CPU time)/(Number of CPUs) used if no wait is involved for I/O or other resources and work load is evenly distributed on each CPU.
Consider the below example: A software application running in 8-CPU UNIX machine creates 4 UNIX processes.
Each of these 4 processes create 2 threads.
Work is evenly distributed across 8 independent threads of execution created for the application.
If no wait for resources is involved, Total CPU time is expected to be 8 times Elapsed real time.