public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7
require 'benchmark'
n = 5_000_000
Benchmark.bm(15) do |x|
x.report("for loop:") { for i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.