-
-
Save splattael/5899463 to your computer and use it in GitHub Desktop.
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/ips' | |
class Foo | |
def bar | |
1 | |
end | |
end | |
foo = Foo.new | |
string_method = "bar" | |
symbol_method = :"bar" | |
Benchmark.ips do |bench| | |
bench.report("send string") {foo.send(string_method)} | |
bench.report("send symbol") {foo.send(symbol_method)} | |
end | |
# Ruby 2.0.0 | |
# Calculating ------------------------------------- | |
# send string 43864 i/100ms | |
# send symbol 57938 i/100ms | |
# ------------------------------------------------- | |
# send string 1373253.2 (±16.4%) i/s - 6667328 in 5.002895s | |
# send symbol 1799751.7 (±9.3%) i/s - 8922452 in 5.000714s | |
# Ruby 1.9.3 | |
# Calculating ------------------------------------- | |
# send string 45224 i/100ms | |
# send symbol 58638 i/100ms | |
# ------------------------------------------------- | |
# send string 1358732.7 (±8.1%) i/s - 6783600 in 5.030276s | |
# send symbol 2094714.2 (±6.7%) i/s - 10437564 in 5.008017s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment