Sha256: f742278f8806477178306af11968e81fc6cb48618cdf9d4ea5711f60d78250cc

Contents?: true

Size: 590 Bytes

Versions: 5

Compression:

Stored size: 590 Bytes

Contents

# encoding: utf-8

require 'rubygems'
require 'bundler/setup'
require 'benchmark/ips'

require 'fast_xs'
require 'escape_utils'

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, from #{url}"

Benchmark.ips do |x|
  x.report "fast_xs" do |times|
    times.times do
      xml.fast_xs
    end
  end

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

  x.compare!
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
escape_utils-1.2.2 benchmark/xml_escape.rb
escape_utils-1.1.1 benchmark/xml_escape.rb
escape_utils-1.2.1 benchmark/xml_escape.rb
escape_utils-1.2.0 benchmark/xml_escape.rb
escape_utils-1.1.0 benchmark/xml_escape.rb