Below are benchmarks of a variety of XML parsers with real world data.
All parsers were used to build a tree, either using XML::Simple or directly in the case of XML::LibXML. No testing was performed on the speed of extracting data from the tree.
Testing aircan (Airfare search results)
info: Parsing with XML::LibXML 1.69 appears successful
info: Parsing with XML::Parser 2.34 (via XML::Simple 2.18) appears successful
info: Parsing with XML::LibXML::SAX 1.69 (via XML::Simple 2.18) appears successful
info: Parsing with XML::LibXML::SAX::Parser 1.69 (via XML::Simple 2.18) appears successful
info: Parsing with XML::SAX::ExpatXS 1.31 (via XML::Simple 2.18) appears successful
info: Parsing with XML::SAX::PurePerl 0.96 (via XML::Simple 2.18) appears successful
Rate XML::SAX::PurePerl XML::LibXML::SAX XML::LibXML::SAX::Parser XML::SAX::ExpatXS XML::Parser XML::LibXML
XML::SAX::PurePerl 0.440/s* -- -51% -76% -88% -91% -99%
XML::LibXML::SAX 0.898/s 104% -- -50% -75% -82% -98%
XML::LibXML::SAX::Parser 1.80/s 309% 101% -- -50% -64% -96%
XML::SAX::ExpatXS 3.57/s 712% 298% 98% -- -29% -93%
XML::Parser 5.04/s 1045% 461% 180% 41% -- -90%
XML::LibXML 50.8/s 11440% 5555% 2720% 1321% 907% --
Testing sysrates (Airfare search results)
info: Parsing with XML::LibXML 1.69 appears successful
info: Parsing with XML::Parser 2.34 (via XML::Simple 2.18) appears successful
info: Parsing with XML::LibXML::SAX 1.69 (via XML::Simple 2.18) appears successful
info: Parsing with XML::LibXML::SAX::Parser 1.69 (via XML::Simple 2.18) appears successful
info: Parsing with XML::SAX::ExpatXS 1.31 (via XML::Simple 2.18) appears successful
info: Parsing with XML::SAX::PurePerl 0.96 (via XML::Simple 2.18) appears successful
s/iter XML::LibXML::SAX XML::SAX::PurePerl XML::LibXML::SAX::Parser XML::SAX::ExpatXS XML::Parser XML::LibXML
XML::LibXML::SAX 2.67* -- -7% -61% -79% -84% -99%
XML::SAX::PurePerl 2.47* 8% -- -58% -77% -83% -99%
XML::LibXML::SAX::Parser 1.04 156% 137% -- -46% -60% -98%
XML::SAX::ExpatXS 0.563 374% 338% 85% -- -26% -96%
XML::Parser 0.417 541% 493% 151% 35% -- -95%
XML::LibXML 0.0223 11874% 10977% 4582% 2426% 1769% --
Testing jacob (Some small UTF-16le file)
info: Parsing with XML::LibXML 1.69 appears successful
info: Parsing with XML::Parser 2.34 (via XML::Simple 2.18) appears successful
info: Parsing with XML::LibXML::SAX 1.69 (via XML::Simple 2.18) appears successful
info: Parsing with XML::LibXML::SAX::Parser 1.69 (via XML::Simple 2.18) appears successful
info: Parsing with XML::SAX::ExpatXS 1.31 (via XML::Simple 2.18) appears successful
error: Unable to parse with XML::SAX::PurePerl 0.96 (via XML::Simple 2.18)! UTF-16:Unrecognised BOM 3f3e**
Rate XML::LibXML::SAX::Parser XML::LibXML::SAX XML::SAX::ExpatXS XML::Parser XML::LibXML
XML::LibXML::SAX::Parser 108/s -- -30% -47% -61% -96%
XML::LibXML::SAX 153/s 42% -- -25% -44% -95%
XML::SAX::ExpatXS 206/s 90% 34% -- -25% -93%
XML::Parser 275/s 155% 79% 34% -- -91%
XML::LibXML 3080/s 2750% 1908% 1396% 1019% --
* — Too few iterations for a reliable count. Suffice it to say they were slooooow.
** — Not only is XML::SAX::PurePerl very slow, it has some encoding-related bugs. Do yourself a favour and remove it from your $perl5lib/XML/SAX/ParserDetails.ini file!!
Links to modules:
Update: Added XML::SAX::ExpatXS.
In reply to Benchmarks of XML Parsers by ikegami
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |