xmldoc() takes ages

From: Date: Thu, 01 May 2003 23:31:06 +0000
Subject: xmldoc() takes ages
Groups: php.internals 
Request: Send a blank email to internals+get-1144@lists.php.net to get a copy of this message
Howdy, I have a 12Meg xml file that I am trying to get PHP 4.3.1 to parse using libxml2 with xmldoc(), and it takes ~ 11 minutes to do this on a P4 1.8Hhz box. The same operation in libxml2's python interface takes 6 seconds. here is my code. Any ideas why it takes 11 minutes? 12Megs of valid xml is large, but not 11 minutes worth of large. <?php //my includes here set_time_limit( 345600 ); $xml = implode('', file("foo_3.xml")); debug_message("parsing xml file of len = ".strlen($xml)); $doc = xmldoc( $xml ); //it takes 11 minutes to get here! debug_message("GOT THE DOC"); exit; ?> The output [waboring@hemna bin]$ time php -f xml.php PHP Notice: DEBUG:(16:04:00):/home/waboring/devel/freemap/bin/xml.php::(11) parsing xml file of len = 11223576 in /home/waboring/devel/freemap/lib/util.inc on line 784 PHP Notice: DEBUG:(16:13:55):/home/waboring/devel/freemap/bin/xml.php::(16) GOT THE DOC in /home/waboring/devel/freemap/lib/util.inc on line 784 <div style="float: left;"> TOTAL EXECUTION TIME: 595.5</div> real 9m56.163s user 8m57.790s sys 0m4.280s python tst.py that comes with libxml2-python package. #!/usr/bin/python -u import sys import libxml2 # Memory debug specific libxml2.debugMemory(1) doc = libxml2.parseFile("tst.xml") if doc.name != "tst.xml": print "doc.name failed" sys.exit(1) root = doc.children print "doc.name = "+root.name #if root.name != "doc": # print "root.name failed" # sys.exit(1) child = root.children #if child.name != "foo": # print "child.name failed" # sys.exit(1) doc.freeDoc() # Memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: print "OK" else: print "Memory leak %d bytes" % (libxml2.debugMemory(1)) libxml2.dumpMemory() output of [waboring@hemna bin]$ time ./tst.py doc.name = MAP OK real 0m3.413s user 0m2.860s sys 0m0.390s Ok, so I'm not 100% sure that the python libxml2.parseFile() does EXACTLY the same php's xmldoc(), but I don't think xmldoc() should take 11 minutes. It also sucks up a ton of ram. Walt

« previous php.internals (#1144) next »