Sha256: ed8ae23cc43777d2399003c1dcd1b614f3daeb753aeab0422d01101d511d6171

Contents?: true

Size: 1.32 KB

Versions: 61

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env ruby -wW1

$: << '.'
$: << '../lib'

if __FILE__ == $0
  while (i = ARGV.index('-I'))
    x,path = ARGV.slice!(i, 2)
    $: << path
  end
end

require 'optparse'
require 'stringio'
require 'multi_xml'

begin
  require 'libxml'
rescue Exception => e
end
begin
  require 'nokogiri'
rescue Exception => e
end
begin
  require 'ox'
rescue Exception => e
end

$verbose = 0
$parsers = []
$iter = 10

opts = OptionParser.new
opts.on("-v", "increase verbosity")                            { $verbose += 1 }
opts.on("-p", "--parser [String]", String, "parser to test")   { |p| $parsers = [p] }
opts.on("-i", "--iterations [Int]", Integer, "iterations")     { |i| $iter = i }
opts.on("-h", "--help", "Show this display")                   { puts opts; Process.exit!(0) }
files = opts.parse(ARGV)

if $parsers.empty?
  $parsers << 'libxml' if defined?(::LibXML)
  $parsers << 'nokogiri' if defined?(::Nokogiri)
  $parsers << 'ox' if defined?(::Ox)
end

files.each do |filename|
  times = { }
  xml = File.read(filename)
  $parsers.each do |p|
    MultiXml.parser = p
    start = Time.now
    $iter.times do |i|
      io = StringIO.new(xml)
      MultiXml.parse(io)
    end
    dt = Time.now - start
    times[p] = Time.now - start
  end
  times.each do |p,t|
    puts "%8s took %0.3f seconds to parse %s %d times." % [p, t, filename, $iter]
  end
end

Version data entries

61 entries across 60 versions & 9 rubygems

Version Path
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/multi_xml-0.5.5/spec/speed.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/1.9.1/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.3.1 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.3.0 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.2.9 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.2.8 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.2.7 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.2.6 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb
plyom_user-0.2.5 vendor/bundle/ruby/2.0.0/gems/multi_xml-0.5.5/spec/speed.rb