Created
July 9, 2012 13:41
-
-
Save sturgill/3076647 to your computer and use it in GitHub Desktop.
Benchmark execution time of & vs include? with strings
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
first = [] | |
second = [] | |
5000.times { |i| first.push "some string here: #{i}" } | |
300.times { |i| second.push "some string here: #{i * 17}" } | |
Benchmark.measure { first & second } | |
Benchmark.measure { first.select { |f| second.include? f } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment