Register now and start sharing your code snippets.
-->

How to benchmark your Ruby code

Ruby posted about 1 year ago by christian

You can easily benchmark your Ruby code like this:

   1  require 'benchmark'
   2  seconds = Benchmark.realtime do
   3  	sleep 1
   4  end
   5  print "#{seconds} elapsed..."

The output should be close to 1 second.

Tagged benchmark, performance, ruby