Elapsed Time and CPU Time for Several Threads
Elapsed time describes the whole observation interval. CPU time for several threads can sum the time each one ran.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace two cores
Two workers running in parallel may each use about one second of CPU during one second of elapsed time. Their aggregate can be about two seconds. Processes and threads describe how the workers share an application.
Account for waiting separately
A worker waiting on I/O can consume little CPU during a long elapsed operation. Check what the operating system's counters include before comparing programs. See long waits and low CPU.[1]
Interpret aggregate CPU time on several cores
Suppose two threads each execute for half a second at the same time on two different cores. The process can accumulate one second of CPU time in roughly half a second of elapsed execution. With one core and no overlap of execution, elapsed time for that CPU work must be longer. See processes and threads.
Thread A CPU: 0.5 s
Thread B CPU: 0.5 s
Sum CPU: 1.0 s
Concurrent on two cores: idealized wall time 0.5 s
Check the definition of a displayed utilization
Some monitoring scales one fully used core to one hundred percent. Other displays normalize to total available cores. Record the convention and distinguish waiting from scheduler overhead.