How are CPU time and CPU usage the same?

Solution 1:

CPU time is allocated in discrete time slices (ticks). For a certain number of time slices, the CPU is busy, other times it is not (which is represented by the idle process). In the picture below the CPU is busy for 6 of the 10 CPU slices. 6/10 = .60 = 60% of busy time (and there would therefore be 40% idle time).

enter image description here

A percentage is defined as "a number or rate that is expressed as a certain number of parts of something divided into 100 parts". So in this case, those parts are discrete slices of time and the something is busy time slices vs idle time slices -- the rate of busy to idle time slices.

Since CPUs operate in GHz (billions of cycles a second). The operating system slices that time in smaller units called ticks. They are not really 1/10 of a second. The tick rate in windows is 10 million ticks in a second and in Linux it is sysconf(_SC_CLK_TCK) (usually 100 ticks per second).

In something like top, the busy CPU cycles are then further broken down into percentages of things like user time and system time. In top on Linux and perfmon in Windows, you will often get a display that goes over 100%, that is because the total is 100% * the_number_of_cpu_cores.

In an operating system, it is the scheduler's job to allocate these precious slices to processes, so the scheduler is what reports this.

Solution 2:

The CPU time is the time that the process is using the CPU - converting it to a percentage is done by dividing by the amount of real time that's passed.

So, if I have a process that uses 1 second of CPU time over a period of 2 seconds, it's using 50% of a CPU.

In the case of your MATLAB process, 217% indicates that it's used 2.17 seconds of CPU time per second over the last sample interval - effectively, monopolizing 2 CPU cores and taking some of a third.