# Why real time can be lower than user time

I have a manuscript transforming video clip documents and also I run it at web server on examination information and also gauge its time by time. In outcome I saw:

real    2m48.326s
user    6m57.498s
sys     0m3.120s


Why live is that a lot less than customer time? Does this have any kind of link with multithreading? Or what else?

Edit: And I assume that manuscript was running circa 2m48s

44
2022-06-07 14:37:37
Source Share

Just to illustrate what has been said, with a two threaded processes doing some calculation.

/*a.c/*
static void  * dosomething () {
unsigned long a,b=1;
for (a=1000000000; a>0; a--) b*=3;
return NULL;
}
main () {
}
/* end of a.c */


compile

gcc a.c -lpthread


(This is just to illustrate, in real life I should have added the -D_REENTRANT flag)

\$ time ./a.out

real    0m7.415s
user    0m13.105s
sys     0m0.032s


(Times are on an Intel Atom that has two slow cores :) )

18
2022-07-25 09:08:15
Source

The result you show is a little bit weird, given that live would generally be larger than the various other 2.

• Real time is wall surface clock time. (what we can gauge with a stop-watch)
• User time is the quantity of time invest in customer - setting within the procedure
• Sys is the CPU time invest in the bit within the procedure

So I intend if the job was done by numerous cpus simultaneously, the CPU time would certainly be greater than the expired wall surface clock time.

Equally as an instance, this is what I get on my Linux system when I release the time find . command. As anticipated the elapsed real time is a lot bigger than the others on this solitary user/single core procedure.

real    0m5.231s
user    0m0.072s
sys     0m0.088s


The general rule is:

• actual < customer: The procedure is CPU bound and also capitalizes on identical implementation on numerous cores/CPUs
• actual ≈ customer: The procedure is CPU bound and also takes no benefit of identical exeuction
• actual > customer: The procedure is I/O bound. Implementation on numerous cores would certainly be of little to no benefit
58
2022-06-07 15:06:32
Source