Skip to content
This repository
tag: 1.1.5
Fetching contributors…

Cannot retrieve contributors at this time

file 23 lines (20 sloc) 0.426 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
require 'benchmark'

def bench_enumerable(bm)
  arr = [false, false, false, false, false, false, false, false, false, false]

  bm.report("1m array.any?, 10-false array") do
    i = 0
    while i<1000000
      arr.any?
      i+=1
    end
  end
end

if $0 == __FILE__
  if ARGV[0]
    ARGV[0].to_i.times {
      Benchmark.bm(40) {|bm| bench_enumerable(bm)}
    }
  else
    Benchmark.bmbm {|bm| bench_enumerable(bm)}
  end
end
Something went wrong with that request. Please try again.