A fork of https://github.com/Synerty/SOAPpy-py3 This is a working tree till fixes get imported upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

84 lines
2.9 KiB

  1. #!/usr/bin/env python
  2. ident = '$Id: speedTest.py,v 1.4 2003/05/21 14:52:37 warnes Exp $'
  3. import time
  4. import sys
  5. sys.path.insert(1, "..")
  6. x='''<SOAP-ENV:Envelope
  7. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  8. xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  9. xmlns:xsd="http://www.w3.org/1999/XMLSchema">
  10. <SOAP-ENV:Body>
  11. <ns1:getRate xmlns:ns1="urn:demo1:exchange" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  12. <country1 xsi:type="xsd:string">USA</country1>
  13. <country2 xsi:type="xsd:string">japan</country2>
  14. </ns1:getRate>
  15. </SOAP-ENV:Body>
  16. </SOAP-ENV:Envelope>'''
  17. x2='''<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.microsoft.com/soap/encoding/clr/1.0 http://schemas.xmlsoap.org/soap/encoding/" xmlns:i3="http://soapinterop.org/xsd" xmlns:i2="http://soapinterop.org/">
  18. <SOAP-ENV:Body>
  19. <i2:echoStructArray id="ref-1">
  20. <return href="#ref-4"/>
  21. </i2:echoStructArray>
  22. <SOAP-ENC:Array id="ref-4" SOAP-ENC:arrayType="i3:SOAPStruct[3]">
  23. <item href="#ref-5"/>
  24. <item href="#ref-6"/>
  25. <item href="#ref-7"/>
  26. </SOAP-ENC:Array>
  27. <i3:SOAPStruct id="ref-5">
  28. <varString xsi:type="xsd:string">West Virginia</varString>
  29. <varInt xsi:type="xsd:int">-546</varInt>
  30. <varFloat xsi:type="xsd:float">-5.398</varFloat>
  31. </i3:SOAPStruct>
  32. <i3:SOAPStruct id="ref-6">
  33. <varString xsi:type="xsd:string">New Mexico</varString>
  34. <varInt xsi:type="xsd:int">-641</varInt>
  35. <varFloat xsi:type="xsd:float">-9.351</varFloat>
  36. </i3:SOAPStruct>
  37. <i3:SOAPStruct id="ref-7">
  38. <varString xsi:type="xsd:string">Missouri</varString>
  39. <varInt xsi:type="xsd:int">-819</varInt>
  40. <varFloat xsi:type="xsd:float">1.495</varFloat>
  41. </i3:SOAPStruct>
  42. </SOAP-ENV:Body>
  43. </SOAP-ENV:Envelope>
  44. '''
  45. # Import in function, because for some reason they slow each other
  46. # down in same namespace ???
  47. def SOAPParse(inxml):
  48. from SOAPpy import parseSOAPRPC
  49. t= time.time()
  50. parseSOAPRPC(inxml)
  51. return time.time()-t
  52. def SAXParse(inxml):
  53. import xml.sax
  54. y = xml.sax.handler.ContentHandler()
  55. t= time.time()
  56. xml.sax.parseString(inxml,y)
  57. return time.time()-t
  58. def DOMParse(inxml):
  59. import xml.dom.minidom
  60. t= time.time()
  61. xml.dom.minidom.parseString(inxml)
  62. return time.time()-t
  63. # Wierd but the SAX parser runs really slow the first time.
  64. # Probably got to load a c module or something
  65. SAXParse(x)
  66. print()
  67. print("Simple XML")
  68. print("SAX Parse, no marshalling ", SAXParse(x))
  69. print("SOAP Parse, and marshalling ", SOAPParse(x))
  70. print("DOM Parse, no marshalling ", DOMParse(x))
  71. print()
  72. print("Complex XML (references)")
  73. print("SAX Parse, no marshalling ", SAXParse(x2))
  74. print("SOAP Parse, and marshalling ", SOAPParse(x2))
  75. print("DOM Parse, no marshalling ", DOMParse(x2))