Time Utility – Why Real Time is Higher Than User and Sys Times Combined

timetime-utility

I execute and time many commands (i.e. nslookup) through SSH and I collect the total time needed for the implied service to complete (i.e. DNS). So I collect the user and sys time as the real time counts time when my process is blocking which I do not need…I guess.

But some of my tests had results as such:

real 3m22.033s
user 0m0.009s
sys 0m0.014s

I execute these tests on limited resources linux boxes but still, the real time is significantly high. Would this only indicate that the box is VERY busy running different processes ? Is it still correct to add up the user and sys times to know how much the service took ?

Best Answer

Real is the total time it took for the process to terminate (that is difference between starting time and stopping time) :

$ time sleep 3

real    0m3.002s
user    0m0.000s
sys     0m0.000s

In this listing, user and sys refer to the time spent respectively in user mode and kernel mode. These do not include the time spent while being inactive, in sleeping state. A process goes sleeping when it deliberately requested it, or when it's waiting for IO (networking/disk access/user interaction) to be available, or waiting for other processes to terminate, for lack of CPU available when the system is under very high load, etc.

Typically, if you call time on wget, real will correspond to the time the download takes, user should be negligible (unless wget is asked to perform intensive data processing), sys should be small (some time might be spent to deal with buffers, moving data back and forth from kernel space to user space.)