-
-
Save k0kubun/b6af6062bc876190e280 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' | |
Benchmark.ips do |x| | |
def old_escapeHTML(string) | |
string.gsub(/['&\"<>]/, CGI::Util::TABLE_FOR_ESCAPE_HTML__) | |
end | |
str = %q[<>&'"] | |
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