def set_parser(): if os.path.isfile('USE_SAX'): xml_pickle.setParser("SAX") elif os.path.isfile('USE_CEXPAT'): xml_pickle.setParser('cEXPAT') else: xml_pickle.setParser('DOM')
def doit(deepcopy=1): f = mk_foo() xml_pickle.setDeepCopy(deepcopy) print("CREATE XML") t1 = time() fh = open('aaa.xml','w') x = xml_pickle.dump(f,fh) fh.close() print("TIME = %f"%(time()-t1)) print("Pickle len = ",os.stat('aaa.xml')[ST_SIZE]) print("minidom pure parse") t1 = time() fh = open('aaa.xml','r') #minidom.parse(fh) fh.close() print("TIME = %f"%(time()-t1)) print("DOM load") t1 = time() fh = open('aaa.xml','r') xml_pickle.setParser("DOM") # default, but just to be sure #o = xml_pickle.load(fh) fh.close() print("TIME = %f"%(time()-t1)) #del o print("SAX load") t1 = time() fh = open('aaa.xml','r') xml_pickle.setParser("SAX") m = xml_pickle.load(fh) fh.close() print("TIME = %f"%(time()-t1)) del m print("cEXPAT load") t1 = time() fh = open('aaa.xml','r') xml_pickle.setParser("cEXPAT") #m = xml_pickle.load(fh) fh.close() print("TIME = %f"%(time()-t1))
def doit(deepcopy=1): f = mk_foo() xml_pickle.setDeepCopy(deepcopy) print "CREATE XML" t1 = time() fh = open('aaa.xml','w') x = xml_pickle.dump(f,fh) fh.close() print "TIME = %f"%(time()-t1) print "Pickle len = ",os.stat('aaa.xml')[ST_SIZE] print "minidom pure parse" t1 = time() fh = open('aaa.xml','r') #minidom.parse(fh) fh.close() print "TIME = %f"%(time()-t1) print "DOM load" t1 = time() fh = open('aaa.xml','r') xml_pickle.setParser("DOM") # default, but just to be sure #o = xml_pickle.load(fh) fh.close() print "TIME = %f"%(time()-t1) #del o print "SAX load" t1 = time() fh = open('aaa.xml','r') xml_pickle.setParser("SAX") m = xml_pickle.load(fh) fh.close() print "TIME = %f"%(time()-t1) del m print "cEXPAT load" t1 = time() fh = open('aaa.xml','r') xml_pickle.setParser("cEXPAT") #m = xml_pickle.load(fh) fh.close() print "TIME = %f"%(time()-t1)