Created
May 29, 2011 02:18
-
-
Save deepthawtz/997398 to your computer and use it in GitHub Desktop.
Symbol.to_proc vs. regular block with arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "benchmark" | |
| n = 1_000_000 | |
| Benchmark.bm do |x| | |
| x.report("symbol to proc ") { Array.new(n, "45").map(&:to_i) } | |
| x.report("regular block with args") { Array.new(n, "45").map {|i| i.to_i} } | |
| end | |
| __END__ | |
| Using /Users/deepthawtz/.rvm/gems/ree-1.8.7-2011.03 | |
| user system total real | |
| symbol to proc 2.500000 0.010000 2.510000 ( 2.517850) | |
| regular block with args 0.330000 0.000000 0.330000 ( 0.333694) | |
| Using /Users/deepthawtz/.rvm/gems/ruby-1.9.2-p180 | |
| user system total real | |
| symbol to proc 0.170000 0.010000 0.180000 ( 0.172500) | |
| regular block with args 0.210000 0.000000 0.210000 ( 0.220909) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment