the reported values can be subdivided in: User time is the amount of time the CPU was busy executing code in user space. System time is the amount of time the CPU was busy executing code in kernel space. If this value is reported for a thread or process, then it represents the amount of time the kernel was doing work on behalf of the executing context, for example, after a thread issued a system call. Idle time (for the whole system only) is the amount of time the CPU was not busy, or, otherwise, the amount of time it executed the System Idle process. Idle time actually measures unused CPU capacity. Steal time (for the whole system only), on virtualized hardware, is the amount of time the operating system wanted to execute, but was not allowed to by the hypervisor. This can happen if the physical hardware runs multiple guest operating system and the hypervisor chose to allocate a CPU time slot to another one. Unix commands for CPU time Unix command top The Unix command top provides CPU time, priority, elapsed real time, and other information for all processes and updates it in real time. Unix command time The Unix command time prints CPU time and elapsed real time for a Unix process. % gcc nextPrimeNumber.c -o nextPrimeNumber % time ./nextPrimeNumber 30000007 Prime number greater than 30000007 is 30000023 0.327u 0.010s 0:01.15 28.6% 0+0k 0+0io 0pf+0w This process took a total of 0.337 seconds of CPU time, out of which 0.327 seconds was spent in user space, and the final 0.010 seconds in kernel mode on behalf of the process. Elapsed real time was 1.15 seconds. The following is the source code of the application nextPrimeNumber which was used in the above example. // nextPrimeNumber.c #include <stdio.h> #include <stdlib.h> int isPrimeNumber(unsigned long int n) { for (int i = 2; i <= (n >> 1); ++i) if (n % i == 0) return 0; return 1; } int main(int argc, char *argv[]) { unsigned long int argument = strtoul(argv[1], NULL, 10), n = argument; while (!isPrimeNumber(++n)); printf("Prime number greater than %lu is %lu\n", argument, n); return 0; } POSIX functions clock() and getrusage() POSIX functions clock() and getrusage() can be used to get CPU time consumed by any process in a POSIX environment. If the process is multithreaded, the CPU time is the sum for all threads. With