By Harry Fuecks

PHP5 XML at 10Meg

By Harry Fuecks

Christian has some interesting thoughts, results and code up here, parsing a 10Mb XML document with PHP5’s XML apis. Highlights the trade off between performance and memory use when using DOM vs. Sax / XMLReader.

Personally a little surprised that XMLReader proved faster than SAX. “Pull style” XML parsers are usually implemented by “re-routing” a SAX parser and from a quick glance at the libxml2 source, it seems to do the same. I guess executing alot of callback functions at a C level is faster than executing them up at the PHP level.

  • chregu

    Harry, you’re right. PHP Functions calls are really really slows compared to C function calls. And in SAX, there are a lot of them (on the PHP level), while with XMLReader you have almost none, just the while() looping.

Get the latest in Front-end, once a week, for free.