Created
April 10, 2017 10:11
-
-
Save FanaHOVA/7e46fd676a87acfbb3669f46b0a1b786 to your computer and use it in GitHub Desktop.
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
require 'benchmark' | |
iterations = 100_000 | |
Benchmark.bmbm(20) do |bm| | |
bm.report('Regexp New') do | |
iterations.times do | |
'menu'[Regexp.new("^\\b#{Regexp.union(['menu'])}\\b")] | |
end | |
end | |
bm.report('Written Regexp') do | |
iterations.times do | |
'menu'[/menu/i] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment