26

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 ?

1 Answer 1

28

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.)

5
  • I'm sorry I added wget to the question, I actually don't time it but thanks for the explanation though. Saying that real includes blocking times such as waiting for network IO makes me think to include that time too because I'm actually testing the network. Thank you. Oct 30, 2012 at 13:45
  • Would you please confirm the following, to test the network's performance and the responsiveness of the queried machine whether it's a DNS server or a pinged machine, is it sufficient to only measure the real time ? Oct 30, 2012 at 14:09
  • @MuhammadGelbana: This real time is just a stopwatch, nothing more. If you let ping run for 3 minutes 22, it will return 3 minutes 22. It's just useless in this case (and actually it's useless as a benchmark most of the time, the result depends on external factors). Oct 30, 2012 at 14:14
  • thanks. But would you know why it didn't timeout ? I read that the default timeout for nslookup is 5 seconds ! Oct 30, 2012 at 14:30
  • The wget part of the answer is interesting and inspiring. For others, here's my time wget xx output
    – Rick
    Oct 19, 2022 at 5:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .