Skip to content

Instantly share code, notes, and snippets.

@sturgill
Created July 9, 2012 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturgill/3076629 to your computer and use it in GitHub Desktop.
Save sturgill/3076629 to your computer and use it in GitHub Desktop.
Benchmark execution time of & vs include? with integers
first = []
second = []
5000.times { |i| first.push i }
300.times { |i| second.push i * 17 }
Benchmark.measure { first & second }
Benchmark.measure { first.select { |f| second.include? f } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment