Skip to content

Instantly share code, notes, and snippets.

@hexgnu
Created January 5, 2012 17:47
Show Gist options
  • Save hexgnu/1566327 to your computer and use it in GitHub Desktop.
Save hexgnu/1566327 to your computer and use it in GitHub Desktop.
require 'set'
require 'benchmark'
Benchmark.bm do |x|
x.report("uniq") do
a = []
10.times do
1_000.times do |i|
a << i % 32
a = a.uniq
end
end
end
x.report("set") do
a = Set.new
10.times do
1_000.times do |i|
a.add(i % 32)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment