Skip to content

Instantly share code, notes, and snippets.

@benlovell
Created December 28, 2016 18:53
Show Gist options
  • Save benlovell/438cfb0310cf67a065df0f1c09122222 to your computer and use it in GitHub Desktop.
Save benlovell/438cfb0310cf67a065df0f1c09122222 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('yours') { 0.class == Integer }
x.report('mine') { 0.is_a? Integer }
x.compare!
end
@benlovell
Copy link
Author

birdperson~/code <master> # ruby two_four_check.rb
Warming up --------------------------------------
               yours   251.061k i/100ms
                mine   259.666k i/100ms
Calculating -------------------------------------
               yours      9.079M (± 5.1%) i/s -     45.442M in   5.018092s
                mine      9.894M (± 4.9%) i/s -     49.596M in   5.025317s

Comparison:
                mine:  9894317.0 i/s
               yours:  9079374.8 i/s - same-ish: difference falls within error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment