Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
Created January 31, 2011 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacaetevha/803666 to your computer and use it in GitHub Desktop.
Save jacaetevha/803666 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment