Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 25 lines (17 sloc) 0.334 kb
#!/usr/bin/env ruby
require "benchmark"
Benchmark.bm(label_width = 10) do |test|
loops = 50000
test.report("for:") do
y = 0
(1..loops).each { |x| y += x }
end
test.report("times:") do
y = 0
loops.times { |x| y += x }
end
test.report("upto:") do
y = 0
1.upto(loops) { |x| y += x }
end
end
Jump to Line
Something went wrong with that request. Please try again.