benchmark/xml_escape.rb in escape_utils-1.2.2 vs benchmark/xml_escape.rb in escape_utils-1.3.0
- old
+ new
@@ -5,25 +5,21 @@
require 'benchmark/ips'
require 'fast_xs'
require 'escape_utils'
-url = "http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml"
+url = "https://raw.githubusercontent.com/darcyliu/google-styleguide/master/cppguide.xml"
xml = `curl -s #{url}`
-xml = xml.force_encoding('binary') if xml.respond_to?(:force_encoding)
+xml = xml.force_encoding('binary')
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
+ x.report "EscapeUtils.escape_xml" do
+ EscapeUtils.escape_xml(xml)
end
- x.report "EscapeUtils.escape_xml" do |times|
- times.times do
- EscapeUtils.escape_xml(xml)
- end
+ x.report "fast_xs" do
+ xml.fast_xs
end
- x.compare!
+ x.compare!(order: :baseline)
end