-
-
Save k0kubun/8e1c7efb1e29991e1382 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/ips' | |
require 'cgi' | |
str = ARGV.first | |
puts "Escape: #{str}" | |
Benchmark.ips do |x| | |
def old_escapeHTML(string) | |
string.gsub(/['&\"<>]/, CGI::Util::TABLE_FOR_ESCAPE_HTML__) | |
end | |
x.report("before") { old_escapeHTML(str) } | |
x.report("after") { CGI.escapeHTML(str) } | |
x.compare! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment