Ruby XML Plugin: nokogiri vs libxml vs hpricot vs rexml

Source: Internet
Author: User
Tags xpath test rails hosting ruby on rails hosting

Disclaimer: every time we 've ve run a piece about benchmarking or performance numbers on Ruby inside, a retraction or significant correction has come out shortly thereafter. benchmarking is hard, uugly, and quite often wrong or biased. it is not useless, however, but if you depend on the results in any way, you shoshould certainly try to do your own benchmarking to confirm.

Last week, libxml-Ruby 1 was released-a significant achievement since it had been under development for seven years. ISuspectedThat it might just Pip nokogiri to the "Fastest way to parse XML in ruby" post and invited people to benchmark them. Turns out .. it ain't so. nokogiri is the fastest.

Aaron Peterson, the developer behind nokogiri, decided to run some tests and he's published the results in a dossier called xml_truth. the benchmarking environment was Ruby 1.8.6 on OS X 10.5 With libxml2 2.7.3 installed. hpricot 0.6.170 competes against nokogiri 1.2.2, libxml-Ruby 1.1.2, and the standard library's rexml.

Aaron put together a whole suite of benchmarks, but if you just want an overview, here's a chart showing the results for in memory parsing of a 14 megabyte XML document. note that the parsing time is in seconds and the y-axis isLogarithmic. Yes, hpricot took over a minute, and rexml took over two minutes, while nokogiri and libxml-Ruby came in at a few seconds each:

Want all the actual numbers? Want to see the actual tests? Want to run them for yourself? Head over to Aaron's project here. Have fun! I'll putting on my flame-retardant jacket in preparation for all of the fallout about how inaccurate these tests are in 3... 1 ..

Update: hpricot 0.7 has been released and Patrick tulskie has run some extra benchmarks.These results show that hpricot beats libxml-Ruby and nokogiri under certain circumstances (quite significantly under an XPATH test ).

Update 2 (March 22,200 9 ):Libxml-Ruby's developer Charles Savage has found why libxml-Ruby lagged behind nokogiri and has resolved it ..:)

Support from: brightbox;-Europe's leading provider of Ruby on Rails hosting.Now with phusion passenger support, each brightbox Server comes with access to a managed MySQL cluster and redundant SAN storage. brightbox also provides managed services for large scale applications and dedicated clusters.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.