Created
August 17, 2017 14:37
-
-
Save ccocchi/933cdfc6e4912307bd6789e7f4a98e13 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' | |
array = %w(abc def ghi jkl) | |
ok = %w(abc jkl) | |
bad = %w(abc yio) | |
Benchmark.ips do |x| | |
x.report('& ok') { (array & ok).size == ok.size } | |
x.report('all ok') { ok.all? { |e| array.include?(e) } } | |
x.report('& bad') { (array & bad).size == bad.size } | |
x.report('all bad') { bad.all? { |e| array.include?(e) } } | |
x.compare! | |
end |
Author
ccocchi
commented
Aug 17, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment