PHP5 XML at 10Meg

By | | PHP

1

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.

Written By:

Harry Fuecks

Harry has been working in corporate IT since 1994, with everything from start-ups to Fortune 100 companies. Outside of office hours he runs phpPatterns: a site dedicated to software design with PHP that aims to raise standards of PHP development. He also maintains Dynamically Typed: SitePoint's PHP blog.

 

{ 1 comment }

chregu May 10, 2004 at 4:43 pm

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.

Comments on this entry are closed.