Published in: Ruby
URL: http://www.ruby-doc.org/core/classes/Benchmark.html
require 'benchmark' n = 50000 Benchmark.bm do |x| x.report { for i in 1..n; a = "1"; end } x.report { n.times do ; a = "1"; end } x.report { 1.upto(n) do ; a = "1"; end } end
You need to login to post a comment.
