Re: xmldoc() takes ages

From: Date: Fri, 02 May 2003 00:14:41 +0000
Subject: Re: xmldoc() takes ages
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-1148@lists.php.net to get a copy of this message
Ok I just changed my script to use the new domxml_open_file(), and it takes 3 seconds. domxml_open_mem() still takes about 9 minutes. I'll just write my xml string to a file in /tmp and then domxml_open_file() on it. I don't think domxml_open_mem() should take that long tho. Yes the 12M string/zval in php is large, but why does domxml_open_mem() vs. domxml_open_file() make that huge of a difference? is this any different in php5 ? Walt On Thu, 2003-05-01 at 16:45, Mark J. Hershenson wrote: > > 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; > > > > ?> > > Given the size, it seems better to use domxml_open_file() and bypass > pulling that all of that data into memory? > > From what I've seen personally and heard as well, that should considerably > streamline the flow of data: > > file -> XML parser > > Instead of: > > file -> lots of zvals for the strings in PHP taking up much more than > the original 12 MB of data -> imploding all those strings into a single > variable -> passing the data by copying into a variable (no reference shown > in example) -> XML parser > > Then you don't have to bring a 12 megabyte datafile into PHP userland by > creating an array for each line and then imploding those lines. > > I'd be interested to hear how much of a difference using domxml_open_file() > would make. > > Hope it helps! > > -- mjh >

« previous php.internals (#1148) next »