Skip to content

Instantly share code, notes, and snippets.

@k0kubun
Last active December 20, 2015 16:48
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 k0kubun/b6af6062bc876190e280 to your computer and use it in GitHub Desktop.
Save k0kubun/b6af6062bc876190e280 to your computer and use it in GitHub Desktop.
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