Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Which of these is the fastest?

View set_benchmark.rb
1 2 3 4 5 6 7 8 9 10 11 12
x = 10000.times.to_a
 
a,b,c = x.dup, x.dup, x.dup
 
Benchmark.measure { 1000.times { out = []; out += a; out += b; out +=c; out.uniq! } }
 
Benchmark.measure { 1000.times { out = Set.new; out += a; out += b; out +=c; } }
 
Benchmark.measure { 1000.times { out = {}; a.each {|e| out[e] ||= 1}; b.each {|e| out[e] ||= 1}; c.each {|e| out[e] ||= 1}; } }
 
 
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.