Skip to content

Instantly share code, notes, and snippets.

@luislee818
Last active September 11, 2015 15:36
Show Gist options
  • Save luislee818/298698122c2f426d34bb to your computer and use it in GitHub Desktop.
Save luislee818/298698122c2f426d34bb to your computer and use it in GitHub Desktop.
set_over_array for rollout gem
require 'benchmark'
describe "Rollout::Feature" do
describe "performance" do
before do
@feature = Rollout::Feature.new(:chat)
end
it "outputs result" do
puts Benchmark.measure {
# 1000 enabled users
(1..1000).each do |num|
@feature.add_user num
end
# 1000000 lookups
(1..1000000).each do |num|
@feature.active?(:chat, num)
end
}
end
end
end
users (with 1M lookup) With Array (sec) With Set (sec)
100 5.411557 3.558224
1000 39.546319 3.583432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment