[XML-SIG] Performance question

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


This is a multipart MIME message.

--==_Exmh_-18413914710
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 
attached.

$ 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
y.html
The Past, Present and Future of Web Services 1 - http://www.webservices.org/ind
ex.php/article/articleview/663/1/24/
The Past, Present and Future of Web Services 2 - 'http://www.webservices.org/in
dex.php/article/articleview/679/1/24/
Serenity through markup - http://adtmag.com/article.asp?id=6807
Tip: Using generators for XML processing - http://www-106.ibm.com/developerwork
s/xml/library/x-tipgenr.html


--==_Exmh_-18413914710
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"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns="http://www.xmethods.net/ws-demo/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:wsid="http://www.xmethods.net/ws-demo/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<Log>
<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>
</Log>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'''

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



--==_Exmh_-18413914710--