-
-
Save 0x0dea/1fb2ef1796ce4a3e8dc5 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/ips' | |
Benchmark.ips do |b| | |
n = '42' | |
b.report('method call') { n.to_i } | |
bound = n.method(:to_i) | |
b.report('bound') { bound.call } | |
unbound = String.instance_method(:to_i) | |
b.report('unbound') { unbound.bind(n).call } | |
b.compare! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment