[XML-SIG] Performance question

Uche Ogbuji uche.ogbuji@fourthought.com
Wed, 06 Nov 2002 18:16:46 -0700

This is a multipart MIME message.

Content-Type: text/plain; charset=us-ascii

> Bryan Pendleton writes:
>  > I was trying to figure out what sort of XML Parser
>  > performance I could expect out of pyxml. I'm using
>  > Python 2.2.2 under Windows 2000 with pyxml 0.8.1.
> My test below was run using Python 2.2.2 on RedHat Linux 7.2 using
> PyXML from CVS.

Just wanted to pitch in results with cDomlette.  Results below, updated script 

$ python dom-parse-perf.py
parser performance test
4DOM - 100 parses took 18.57 seconds, or 0.19 seconds/parse
minidom - 100 parses took 1.51 seconds, or 0.02 seconds/parse
cDomlette - 100 parses took 1.49 seconds, or 0.01 seconds/parse

Athlon 1800+ with 768MB RAM, Debian sarge 2.4.19, Python 2.2.

Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Python&XML column: 2. Introducing PyXML - http://www.xml.com/pub/a/2002/09/25/p
The Past, Present and Future of Web Services 1 - http://www.webservices.org/ind
The Past, Present and Future of Web Services 2 - 'http://www.webservices.org/in
Serenity through markup - http://adtmag.com/article.asp?id=6807
Tip: Using generators for XML processing - http://www-106.ibm.com/developerwork

Content-Type: text/plain ; name="dom-parse-perf.py"; charset=us-ascii
Content-Description: dom-parse-perf.py
Content-Disposition: attachment; filename="dom-parse-perf.py"

import time
from xml.dom.ext.reader import PyExpat
from xml.dom import expatbuilder
from Ft.Xml.Domlette import NonvalidatingReader

def parseString(s):
    reader = PyExpat.Reader()
    return reader.fromString(s)

def doTest(numTimes, s, parse, label):
    t1 = time.time()
    for i in range(numTimes):
        d = parse(s)
    t2 = time.time()
    print label, '- %d parses took %.2f seconds, or %.2f seconds/parse' % \
        ( numTimes, t2 - t1, (t2 - t1) / numTimes )
    return d

s1 = '''<?xml version="1.0" encoding="UTF-8"?>
<participant id="83b3f0" xsi:type="xsd:string">built-in supplier</participant>
<role id="848ac0" xsi:type="xsd:string">Supplier</role>
<message id="8dbb60" xsi:type="xsd:string">Processing catalog request</message>
<indentLevel xsi:type="xsd:int">0</indentLevel>
<timestamp id="1284630" xsi:type="xsd:string">Tue Oct 29 15:03:48 2002</timestamp>

print 'parser performance test'
doTest(100, s1, parseString, "4DOM")
doTest(100, s1, expatbuilder.parseString, "minidom")
doTest(100, s1, NonvalidatingReader.parseString, "cDomlette")