Last active
September 6, 2019 14:02
-
-
Save mahemoff/7232648e1ccb9d23e0f4670913400bd8 to your computer and use it in GitHub Desktop.
in versus include
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in | |
0.000007 0.000000 0.000007 ( 0.000004) | |
include | |
0.000004 0.000000 0.000004 ( 0.000023) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with
1000.times
inside the measure, very close