Skip to content

Instantly share code, notes, and snippets.

@mahemoff mahemoff/bench.rb
Last active Sep 6, 2019

Embed
What would you like to do?
in versus include
#!/usr/bin/env ruby
require 'benchmark'
require 'active_support/all'
puts 'in', Benchmark.measure { 90000.in?(1..99000)}
puts 'include', Benchmark.measure { (1..99000).include? 90000 }
in
0.000007 0.000000 0.000007 ( 0.000004)
include
0.000004 0.000000 0.000004 ( 0.000023)
@mahemoff

This comment has been minimized.

Copy link
Owner Author

commented Sep 6, 2019

with 1000.times inside the measure, very close

in
  0.000158   0.000018   0.000176 (  0.000173)
include
  0.000181   0.000021   0.000202 (  0.000201)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.