#!/usr/bin/env python
ident = '$Id: speedTest.py,v 1.4 2003/05/21 14:52:37 warnes Exp $'
import time
import sys
sys.path.insert(1, "..")
x='''
USA
japan
'''
x2='''
West Virginia
-546
-5.398
New Mexico
-641
-9.351
Missouri
-819
1.495
'''
# Import in function, because for some reason they slow each other
# down in same namespace ???
def SOAPParse(inxml):
from SOAPpy import parseSOAPRPC
t= time.time()
parseSOAPRPC(inxml)
return time.time()-t
def SAXParse(inxml):
import xml.sax
y = xml.sax.handler.ContentHandler()
t= time.time()
xml.sax.parseString(inxml,y)
return time.time()-t
def DOMParse(inxml):
import xml.dom.minidom
t= time.time()
xml.dom.minidom.parseString(inxml)
return time.time()-t
# Wierd but the SAX parser runs really slow the first time.
# Probably got to load a c module or something
SAXParse(x)
print
print "Simple XML"
print "SAX Parse, no marshalling ", SAXParse(x)
print "SOAP Parse, and marshalling ", SOAPParse(x)
print "DOM Parse, no marshalling ", DOMParse(x)
print
print "Complex XML (references)"
print "SAX Parse, no marshalling ", SAXParse(x2)
print "SOAP Parse, and marshalling ", SOAPParse(x2)
print "DOM Parse, no marshalling ", DOMParse(x2)