Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (26 sloc) 0.956 kB
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
Jump to Line
Something went wrong with that request. Please try again.