Re: xmldoc() takes ages
| From: | Mark J. Hershenson | Date: | Thu, 01 May 2003 23:45:58 +0000 |
| Subject: | Re: xmldoc() takes ages | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-1147@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;
>
> ?>
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