Created
January 16, 2016 01:14
-
-
Save asterite/8bdc0e46426d71d41fdc 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" | |
CONSTANT = %w(foo bar baz) | |
Benchmark.ips do |x| | |
x.report("literal") { %w(foo bar baz).include?("foo") } | |
x.report("constant") { CONSTANT.include?("foo") } | |
end |
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
Calculating ------------------------------------- | |
literal 81.923k i/100ms | |
constant 111.304k i/100ms | |
------------------------------------------------- | |
literal 2.104M (± 4.1%) i/s - 10.568M | |
constant 4.386M (± 4.5%) i/s - 21.927M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment