Groovy Speed 2 - Groovin' with Groovy | [ Prev | Home | Next ] |
def benchmark(n) start = Time.now n.times { yield } delta = Time.now - start (delta.to_f / n.to_f) * 1000 end def fact(n) (2..n).inject(1) { |f, i| f * i } end t = benchmark(10000) { fact(10) } puts "Ruby: #{1000*t} MicroSeconds per call"
Ruby: 99.5389 MicroSeconds per call
Copyright 2004 by Jim Weirich (Some Rights Reserved) |