Sha256: 9fba28f10f20878b3c8b64ed4011924e03884c6c9ce50e20146110f1956b87bf

Contents?: true

Size: 712 Bytes

Versions: 5

Compression:

Stored size: 712 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 'builder'
require 'escape_utils'

times = 100
url = "http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml"
xml = `curl -s #{url}`
xml = xml.force_encoding('binary') if xml.respond_to?(:force_encoding)
puts "Escaping #{xml.bytesize} bytes of xml #{times} times, from #{url}"

Benchmark.bmbm do |x|
  x.report "Builder::String.to_xs" do
    times.times do
      xml.to_xs
    end
  end

  x.report "EscapeUtils.escape_xml" do
    times.times do
      EscapeUtils.escape_xml(xml)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
escape_utils-1.0.1 benchmark/xml_escape.rb
escape_utils-1.0.0 benchmark/xml_escape.rb
escape_utils-0.3.2 benchmark/xml_escape.rb
escape_utils-0.3.1 benchmark/xml_escape.rb
escape_utils-0.3.0 benchmark/xml_escape.rb