mwmitchell/rsolr — pull request #48 by mbklein (2012-04-04 19:18:25+00:00)
Title: Optionally use Nokogiri::XML::Builder for huge speed increase over Builder::XmlMarkup

I added code to `RSolr::Xml::Generator` that will cause the underlying XML document build to use Nokogiri instead of Builder. The choice is driven by a single class attribute, `RSolr::Xml::Generator.use_nokogiri`. It defaults to `false`, doesn't attempt to require Nokogiri unless it's set to `true` (thereby avoiding an explicit runtime dependency), and is otherwise completely transparent to the rest of RSolr as well as RSolr consumers.

Compelling reason to include both:
On MRI Ruby, Nokogiri is 8.5x as fast as Builder. ([0.66s](http://www.stanford.edu/~mbklein/rsolr_profiles/profile_nokogiri.html#RSolr__Xml__Generator_add_2195898800) vs. [5.64s](http://www.stanford.edu/~mbklein/rsolr_profiles/profile_builder.html#RSolr__Xml__Generator_add_2220845480) for 10 documents).
On JRuby, Builder is 2x as fast as Nokogiri. ([1.60s](http://www.stanford.edu/~mbklein/rsolr_profiles/profile_builder.txt) vs. [3.13s](http://www.stanford.edu/~mbklein/rsolr_profiles/profile_nokogiri.txt) for the same 10 documents).

All API tests pass in both Builder and Nokogiri mode under MRI 1.8.7 & 1.9.3 as well as jruby 1.6.7.