--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To post to this group, send email to nokogi...@googlegroups.com.
To unsubscribe from this group, send email to nokogiri-tal...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nokogiri-talk?hl=en.
I just want to say thanks to the fine developers of Nokogiri.
I only use Xpath stuff in my integration tests. I've been using REXML
for years and have never tried an alternative. I've know that REXML
isn't the fasted thing around, but it has always worked for me, albeit
slow at times.
Well, last night I created a test that involves posting lots of
comments to a blog post. A single test that executes exactly (2)
simple Xpath queries took over 50 seconds! I seriously thought
something was wrong with my computer. I checked my CPU temp and
ensured speed step didn't kick in and crank my processor down.
Long story short, I just don't have 50 seconds to spare. I installed
Nokogiri and converted my tests to use Nokogiri. Now my test takes
0.18 seconds!!!!!
AMAZING!!!! You guys just saved me 49.82 seconds!
The CSS selectors look cool too. Now, I'll probably never use REXML
again. Cheers guys!
Clint
There are a few costs you pay when using REXML. I'll list a few I can
think of off the top of my head:
1. String interning: libxml2 keeps a dictionary of strings which keeps
memory low. For example, if an attribute is named "foo", there is
only one copy of the "foo" string in memory. When someone in ruby
land requests the string, we copy it and provide a ruby object. This
is not true in REXML.
2. In REXML, Ruby objects are created for every node, whether you need
them or not. nokogiri is lazy about Ruby object creation. libxml2
builds a tree of nodes in memory. Nokogiri keeps a pointer to the
tree, but does not wrap any of the objects until someone in Ruby land
specifically requests that object.
3. Method calls on XPath traversal. REXML must call ruby methods when
traversing the document tree if someone makes an xpath query. libxml2
merely has to follow pointers.
There's more stuff, but I can't think of it now.
--
Aaron Patterson
http://tenderlovemaking.com/