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

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


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


Please check this gem:https://github.com/igorkasyanchuk/benchmark_methods

No more code like this:

t = Time.nowuser.calculate_reportputs Time.now - t

Now you can do:

benchmark :calculate_report # in class

And just call your method

user.calculate_report