[XML-SIG] Performance question

Bryan Pendleton bryanpendleton2000@yahoo.com
Mon, 4 Nov 2002 13:57:30 -0800 (PST)


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.

I wrote the following trivial little program, and it
seems to be showing me that I can get between 20 and
25 parses per second on my PC. Is this a reasonable
result to achieve? I was hoping to be able to get 
many hundreds of parses a second, so getting only 20
or so was rather alarming.

Is there anything I can do to make this code faster?

thanks,

bryan

============== parserPerformance.py ===================
import time
from xml.dom.ext.reader import PyExpat

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

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

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)


__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/