Created
March 2, 2018 18:58
-
-
Save djberg96/382557d33b91ca8cb642d6a84cf89fbc 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' | |
require 'set' | |
ary = [] | |
5000.times { ary << rand.round(6) } | |
set = ary.to_set | |
Benchmark.ips do |x| | |
x.report("Array#include?") { ary.include?(rand.round(6))} | |
x.report("Set#include?") { set.include?(rand.round(6))} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment