Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sturgill on github.
  • I am sturgill (https://keybase.io/sturgill) on keybase.
  • I have a public key ASAm4c__c2FxIf4x5u82Wo7tccB0QKKwsukerLGT3Jwx6go

To claim this, I am signing this object:

@sturgill
sturgill / HashComparison.rb
Created July 9, 2012 13:42
Benchmark execution time of & vs include? with hashes
first = []
second = []
5000.times { |i| first.push({ :integer => i, :string => "some string here: #{i}" }) }
300.times { |i| second.push({ :integer => i * 17, :string => "some string here: #{i * 17}" }) }
Benchmark.measure { first & second }
Benchmark.measure { first.select { |f| second.include? f } }
@sturgill
sturgill / StringComparison.rb
Created July 9, 2012 13:41
Benchmark execution time of & vs include? with strings
first = []
second = []
5000.times { |i| first.push "some string here: #{i}" }
300.times { |i| second.push "some string here: #{i * 17}" }
Benchmark.measure { first & second }
Benchmark.measure { first.select { |f| second.include? f } }
@sturgill
sturgill / IntegerComparison.rb
Created July 9, 2012 13:36
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 } }