How to benchmark your Ruby code
You can easily benchmark your Ruby code like this:
require 'benchmark'
seconds = Benchmark.realtime do
sleep 1
end
print "#{seconds} elapsed..."
The output should be close to 1 second.
You can easily benchmark your Ruby code like this:
require 'benchmark'
seconds = Benchmark.realtime do
sleep 1
end
print "#{seconds} elapsed..."
The output should be close to 1 second.