Skip to content

Instantly share code, notes, and snippets.

@dcadenas
Created September 30, 2010 05:57
Show Gist options
  • Select an option

  • Save dcadenas/604100 to your computer and use it in GitHub Desktop.

Select an option

Save dcadenas/604100 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'benchmark'
Benchmark.bm do|b|
b.report("block") do
(1..1000000).map {|n| Math.log(n) }
end
b.report("to_proc") do
(1..1000000).map &Math.method(:log)
end
end
__END__
user system total real
block 1.200000 0.070000 1.270000 ( 1.280115)
to_proc 1.430000 0.030000 1.460000 ( 1.461956)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment