Sha256: 53f55ac0f7cb0c0c0e2dc947c7f96dd54226013a3403baead1bc82177ba7bafe

Contents?: true

Size: 940 Bytes

Versions: 6

Compression:

Stored size: 940 Bytes

Contents

require "benchmark"
require File.dirname(__FILE__) + "/../lib/xml_node"

class XmlNode
  def to_xml_as_array
    xml = []
    document = REXML::Document.new
    document << REXML::XMLDecl.new('1.0')
    document << @element
    document.write( xml, 0)
    xml.to_s
  end

  def to_xml_no_format
    xml = ''
    document = REXML::Document.new
    document << REXML::XMLDecl.new('1.0')
    document << @element
    document.write( xml)
    xml
  end
end

TESTS = 10000

Benchmark.bmbm do |results|
  results.report { TESTS.times do XmlNode.new('feed') { |n| n << XmlNode.new('element', 'test'); n << XmlNode.new('element') }.to_xml end }
  results.report { TESTS.times do XmlNode.new('feed') { |n| n << XmlNode.new('element', 'test'); n << XmlNode.new('element') }.to_xml_as_array end }
  results.report { TESTS.times do XmlNode.new('feed') { |n| n << XmlNode.new('element', 'test'); n << XmlNode.new('element') }.to_xml_no_format end }
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
active_shipping-0.12.6 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-1.0.0.pre4 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-1.0.0.pre3 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-1.0.0.pre2 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-1.0.0.pre1 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.12.5 lib/vendor/xml_node/benchmark/bench_generation.rb