Last active
May 10, 2019 10:07
-
-
Save ccocchi/3b95beb0a95563ce16a764c375d841d6 to your computer and use it in GitHub Desktop.
Regexp VS start_with?
This file contains hidden or 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
require 'benchmark/ips' | |
require 'uri' | |
str = 'https://www.facebook.com/' | |
Benchmark.ips do |x| | |
x.report('start_with?') { str.start_with?('https://', 'http://') } | |
x.report('match?') { str.match?(URI::regexp) } | |
x.report('=~') { str =~ URI::regexp } | |
x.compare! | |
end |
Author
ccocchi
commented
May 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment