Skip to content

Instantly share code, notes, and snippets.

@FanaHOVA
Created April 10, 2017 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FanaHOVA/7e46fd676a87acfbb3669f46b0a1b786 to your computer and use it in GitHub Desktop.
Save FanaHOVA/7e46fd676a87acfbb3669f46b0a1b786 to your computer and use it in GitHub Desktop.
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