benchmark/html_escape.rb in escape_utils-0.1.4 vs benchmark/html_escape.rb in escape_utils-0.1.5

- old
+ new

@@ -7,30 +7,39 @@ require 'rack' require 'erb' require 'cgi' require 'haml' +require 'fast_xs_extra' +require 'faster_html_escape' require 'escape_utils' module HamlBench extend Haml::Helpers end times = 100 -url = "http://maps.google.com" +url = "http://en.wikipedia.org/wiki/Line_of_succession_to_the_British_throne" html = `curl -s #{url}` -puts "Escaping #{html.bytesize} bytes of html from #{url}" +puts "Escaping #{html.bytesize} bytes of html #{times} times, from #{url}" Benchmark.bmbm do |x| x.report do puts "Rack::Utils.escape_html" times.times do Rack::Utils.escape_html(html) end end x.report do + puts "Haml::Helpers.html_escape" + times.times do + HamlBench.html_escape(html) + end + end + + x.report do puts "ERB::Util.html_escape" times.times do ERB::Util.html_escape(html) end end @@ -41,12 +50,19 @@ CGI.escapeHTML(html) end end x.report do - puts "Haml::Helpers.html_escape" + puts "FasterHTMLEscape.html_escape" times.times do - HamlBench.html_escape(html) + FasterHTMLEscape.html_escape(html) + end + end + + x.report do + puts "fast_xs_extra#fast_xs_html" + times.times do + html.fast_xs_html end end x.report do puts "EscapeUtils.escape_html" \ No newline at end of file