benchmark/xml_escape.rb in escape_utils-1.0.1 vs benchmark/xml_escape.rb in escape_utils-1.1.0
- old
+ new
@@ -1,29 +1,29 @@
# 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 'bundler/setup'
+require 'benchmark/ips'
-require 'builder'
+require 'fast_xs'
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}"
+puts "Escaping #{xml.bytesize} bytes of xml, from #{url}"
-Benchmark.bmbm do |x|
- x.report "Builder::String.to_xs" do
+Benchmark.ips do |x|
+ x.report "fast_xs" do |times|
times.times do
- xml.to_xs
+ xml.fast_xs
end
end
- x.report "EscapeUtils.escape_xml" do
+ x.report "EscapeUtils.escape_xml" do |times|
times.times do
EscapeUtils.escape_xml(xml)
end
end
+
+ x.compare!
end