Skip to content

Instantly share code, notes, and snippets.

@leosoto
Last active September 11, 2017 03:59
Show Gist options
  • Save leosoto/338d4015c44a57f65fbaf21b61c7de15 to your computer and use it in GitHub Desktop.
Save leosoto/338d4015c44a57f65fbaf21b61c7de15 to your computer and use it in GitHub Desktop.
require 'benchmark'
str = "<p>"
50.times do
str += " "
elapsed_time = Benchmark.measure {
str.gsub(/\<p\>(\<br\s*\/?\>|\s+)*<\/p\>/, '')
}.utime
puts "largo: #{str.length}; tiempo: #{elapsed_time}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment