Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Benchmark module: meanings of "user", "system", and "real"?

Experimenting with Ruby's Benchmark module...

>> Benchmark.bm(7) { |b| b.report('Report:') { s = '' ; 10000.times { s += 'a' } }  }
             user     system      total        real
Report:  0.150000   0.010000   0.160000 (  0.156361)

What are the meanings of "user", "system", and "real"?

like image 454
Ethan Avatar asked Oct 23 '09 22:10

Ethan


1 Answers

These are the same times that the Unix time command or other typical benchmarking tools would report:

  • user: the amount of time spent executing userspace code (i.e.: your code),
  • system: the amount of time spent executing kernel code and
  • real: the "real" amount of time it took to execute the code (i.e. system + user + time spent waiting for I/O, network, disk, user input, etc.). Also known as "wallclock time".
like image 147
Jörg W Mittag Avatar answered Nov 09 '22 07:11

Jörg W Mittag