Sha256: fcf2bc4126421241364d0a85f28b501b027dbfc36ef48c9de71f96e6aa793845

Contents?: true

Size: 956 Bytes

Versions: 48

Compression:

Stored size: 956 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

48 entries across 48 versions & 6 rubygems

Version Path
omniship-0.4.7 lib/vendor/xml_node/benchmark/bench_generation.rb
omniship-0.4.6 lib/vendor/xml_node/benchmark/bench_generation.rb
omniship-0.4.5 lib/vendor/xml_node/benchmark/bench_generation.rb
omniship-0.4.1 lib/vendor/xml_node/benchmark/bench_generation.rb
bcarpenter-active_shipping-0.0.2 lib/vendor/xml_node/benchmark/bench_generation.rb
bcarpenter-active_shipping-0.0.5 lib/vendor/xml_node/benchmark/bench_generation.rb
bcarpenter-active_shipping-0.0.6 lib/vendor/xml_node/benchmark/bench_generation.rb
bcarpenter-active_shipping-0.0.7 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.12.4 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.12.3 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.12.2 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.12.1 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.12.0 lib/vendor/xml_node/benchmark/bench_generation.rb
omniship-0.4.0 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.11.2 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.11.1 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.11.0 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.10.1 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.10.0 lib/vendor/xml_node/benchmark/bench_generation.rb
active_shipping-0.9.15 lib/vendor/xml_node/benchmark/bench_generation.rb