Guest User

Untitled

a guest
Aug 10th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. ids = (1..1_000_000).to_a; nil
  2. x = rand(1_000_000)
  3.  
  4. Benchmark.realtime do
  5. the_set = ids.to_set
  6. 1000.times do
  7. the_set.include?(x)
  8. end
  9. end
  10. # => 0.7543990612030029
  11.  
  12. Benchmark.realtime do
  13. 1000.times do
  14. ids.include?(x)
  15. end
  16. end
  17. # => 44.60349249839783
Add Comment
Please, Sign In to add comment