Sha256: 03694f4f6b03a6239e02ae6930b344f146165fdb678460bd83106da2e8b43637

Contents?: true

Size: 755 Bytes

Versions: 5

Compression:

Stored size: 755 Bytes

Contents

# encoding: utf-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'

require 'cgi'
require 'haml'
require 'escape_utils'

module HamlBench
  extend Haml::Helpers
end

times = 100
url = "http://maps.google.com"
html = `curl -s #{url}`
escaped_html = EscapeUtils.escape_html(html)
puts "Unescaping #{escaped_html.bytesize} bytes of escaped html from #{url}"

Benchmark.bmbm do |x|
  x.report do
    puts "CGI.unescapeHTML"
    times.times do
      CGI.unescapeHTML(escaped_html)
    end
  end

  x.report do
    puts "EscapeUtils.unescape_html"
    times.times do
      EscapeUtils.unescape_html(escaped_html)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
escape_utils-0.1.4 benchmark/html_unescape.rb
escape_utils-0.1.3 benchmark/html_unescape.rb
escape_utils-0.1.2 benchmark/html_unescape.rb
escape_utils-0.1.1 benchmark/html_unescape.rb
escape_utils-0.1.0 benchmark/unescape.rb