Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

20 lines (15 sloc) 268 Bytes
require "benchmark/ips"
def do_something(n)
4*n + 2
end
def fast
[1, 2, 3].map { |n| do_something(n) }
end
def slow
[1, 2, 3].map(&method(:do_something))
end
Benchmark.ips do |x|
x.report("normal") { fast }
x.report("&method") { slow }
x.compare!
end
You can’t perform that action at this time.