-
-
Save RX14/db69279bbc4a3834f6300acb79c9f0e4 to your computer and use it in GitHub Desktop.
This file contains 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" | |
RANGE = (1..100) | |
def slow | |
RANGE.map { |i| i.to_s } | |
end | |
def fast | |
RANGE.map(&.to_s) | |
end | |
Benchmark.ips do |x| | |
x.report("Block") { slow } | |
x.report("Symbol#to_proc") { fast } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment