1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/performance.py Sun Jan 16 02:29:50 2005 +0000
1.3 @@ -0,0 +1,50 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +import macrotest
1.7 +import xml.dom.minidom
1.8 +import libxml2dom
1.9 +import xml.dom
1.10 +import time
1.11 +import sys
1.12 +
1.13 +def find_root(d):
1.14 + root = None
1.15 +
1.16 + for n in d.childNodes:
1.17 + if n.nodeType == xml.dom.Node.ELEMENT_NODE:
1.18 + root = n
1.19 + break
1.20 +
1.21 + return root
1.22 +
1.23 +def test_import(d):
1.24 + d2 = xml.dom.minidom.getDOMImplementation().createDocument("nsD", "newdoc", None)
1.25 + imported = d2.importNode(find_root(d), 1)
1.26 + d2.replaceChild(imported, find_root(d2))
1.27 + return d, d2
1.28 +
1.29 +def test_import2(d):
1.30 + d2 = libxml2dom.createDocument("nsD", "newdoc", None)
1.31 + imported = d2.importNode(find_root(d), 1)
1.32 + d2.replaceChild(imported, find_root(d2))
1.33 + return d, d2
1.34 +
1.35 +x2_d = macrotest.parseFile(sys.argv[1])
1.36 +
1.37 +t = time.time()
1.38 +x2_d1, x2_d2 = macrotest.test_import(x2_d)
1.39 +print "Time", time.time() - t, "seconds"
1.40 +
1.41 +d = xml.dom.minidom.parse(sys.argv[1])
1.42 +
1.43 +t = time.time()
1.44 +d1, d2 = test_import(d)
1.45 +print "Time", time.time() - t, "seconds"
1.46 +
1.47 +d = libxml2dom.parse(sys.argv[1])
1.48 +
1.49 +t = time.time()
1.50 +d1, d2 = test_import2(d)
1.51 +print "Time", time.time() - t, "seconds"
1.52 +
1.53 +# vim: tabstop=4 expandtab shiftwidth=4