CPU and Processor Time Counter
Read this introduction to computer performance and information about computing processor time. In most programming languages, there is a process to measure elapsed time, such as time() in C. By subtracting the time at the beginning of a process from the time at the end you get the total time for a particular operation. Usually short operations are put in a loop that repeats the operation a sufficient number of times to get an accurate measurement.
About
CPU time: The count of cycles, also known as clockticks, forms the basis for measuring how long a program takes to execute.
Definition
How do you measure Execution Time?
CPU Time | Running which code |
---|---|
Kernel (Sys) Time | Operating system code - the time of CPU spent on the kernel (system) code only within the given process - other processes and the time when our process is blocked are not included. |
User Time | Time CPU spends running the program code (ie CPU time spent on non-kernel (user-mode) code only within the given process – so other processes and the time when our process is blocked are not included.). |
Total time | User + Kernel |
Real Time | Wall clock (total elapsed time) (can be lower than total time because of parallelism or longer because of wait) - user-perceived time it took to execute the command – from the start to the end of the call, including time slices used by other processes and the time when our process is blocked (e.g. I/O waiting) |
Process Explorer
To see CPU time, you can look at the performance tab of a process in Process Explorer:
Red in the CPU usage graph indicates CPU usage in kernel-mode whereas green is the sum of kernel-mode and user-mode execution.
A data collector set can be configured via logman.exe to log the “% Processor Time” counter in the “Processor Information” object for this purpose.
Formula
Every conventional processor has a clock with a fixed cycle time (or clock rate). At every CPU cycle, an instruction is executed.
Putting it all together:
where:
Note:
-
CPI is somewhat artificial (since it is computed from the other numbers) but it seems to be intuitive and useful.
-
Use dynamic instruction count (#instructions executed), not static (#instructions in compiled code)
Performance
Performance is the response time distributed through the request lifetime.
Busy vs Wait
CPU Performance
System Performance
Units (MHz to ns)
-
Rate is often measured in MHz (millions of cycles per second)
-
Time is often measured in ns (nanoseconds)
Source: DataCademia, https://datacadamia.com/counter/resource/system/cpu/time
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.