<commit_before>$:.push File.expand_path('../../lib', __FILE__)

require 'benchmark'
require 'xmlhasher'
begin
  require 'nori'
rescue
  puts "nori gem in not install, run 'gem install nori'"
end
begin
  require 'active_support/core_ext/hash/conversions'
rescue
  puts "active_support gem in not install, run 'gem install activesupport'"
end
begin
  require 'xmlsimple'
rescue
  puts "xmlsimple gem in not install, run 'gem install xml-simple'"
end
begin
  require 'nokogiri'
rescue
  puts "nokogiri gem in not install, run 'gem install nokogiri'"
end
begin
  require 'libxml'
rescue
  puts "libxml gem in not install, run 'gem install libxml-ruby'"
end


runs = 100
xml = File.read(File.expand_path('../../test/fixtures/institution.xml', __FILE__))
puts 'Benchmarking conversion of small xml from text to Hash'
Benchmark.bm 10 do |x|
  ActiveSupport::XmlMini.backend = ActiveSupport::XmlMini_REXML
  x.report 'activesupport(rexml)   ' do
    runs.times { Hash.from_xml(xml) }
  end

  ActiveSupport::XmlMini.backend = 'LibXML'
  x.report 'activesupport(libxml)  ' do
    runs.times { Hash.from_xml(xml) }
  end

  ActiveSupport::XmlMini.backend = 'Nokogiri'
  x.report 'activesupport(nokogiri)' do
    runs.times { Hash.from_xml(xml) }
  end

  x.report 'xmlsimple              ' do
    runs.times { XmlSimple.xml_in(xml) }
  end

  x.report 'nero                   ' do
    runs.times { Nori.new(:advanced_typecasting => false).parse(xml) }
  end

  x.report 'xmlhasher              ' do<commit_msg>more typo fixes<commit_after>$:.push File.expand_path('../../lib', __FILE__)

require 'benchmark'
require 'xmlhasher'
begin
  require 'nori'
rescue
  puts "nori gem in not installed, run 'gem install nori'"
end
begin
  require 'active_support/core_ext/hash/conversions'
rescue
  puts "active_support gem in not installed, run 'gem install activesupport'"
end
begin
  require 'xmlsimple'
rescue
  puts "xmlsimple gem in not installed, run 'gem install xml-simple'"
end
begin
  require 'nokogiri'
rescue
  puts "nokogiri gem in not installed, run 'gem install nokogiri'"
end
begin
  require 'libxml'
rescue
  puts "libxml gem in not installed, run 'gem install libxml-ruby'"
end


runs = 100
xml = File.read(File.expand_path('../../test/fixtures/institution.xml', __FILE__))
puts 'Benchmarking conversion of small xml from text to Hash'
Benchmark.bm 10 do |x|
  ActiveSupport::XmlMini.backend = ActiveSupport::XmlMini_REXML
  x.report 'activesupport(rexml)   ' do
    runs.times { Hash.from_xml(xml) }
  end

  ActiveSupport::XmlMini.backend = 'LibXML'
  x.report 'activesupport(libxml)  ' do
    runs.times { Hash.from_xml(xml) }
  end

  ActiveSupport::XmlMini.backend = 'Nokogiri'
  x.report 'activesupport(nokogiri)' do
    runs.times { Hash.from_xml(xml) }
  end

  x.report 'xmlsimple              ' do
    runs.times { XmlSimple.xml_in(xml) }
  end

  x.report 'nero                   ' do
    runs.times { Nori.new(:advanced_typecasting => false).parse(xml) }
  end

  x.report 'xmlhasher              ' do
{'fraction_non_alphanumeric': 0.10956175298804781, 'fraction_numerical': 0.0033200531208499337, 'mean_word_length': 3.558245083207262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 46}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4082457', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1057, 'n_words': 283}