# REXML Performance

**URL:** <https://rubytalk.org/t/rexml-performance/10295>\
**Category:** ruby-talk\
**Created:** [24 February 2004 19:04 UTC](https://rubytalk.org/t/rexml-performance/10295 "2004-02-24T19:04:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazyfishpants](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@crazyfishpants](https://rubytalk.org/u/crazyfishpants)\
**Post date:** [24 February 2004 19:04 UTC](https://rubytalk.org/t/rexml-performance/10295/1 "2004-02-24T19:04:49Z")

</div>

I am using the Tree Parser in REXML. While parsing short documents performance is great, performance is significantly impacted when parsing large documents. Specifically, this occurs when the following line is executed:

xmlDoc = Document.new(File.new(fileToParse))

Any ideas?

---

<div class="post-metadata">

**Author:** ![Steven\_Jenkins](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@Steven\_Jenkins](https://rubytalk.org/u/Steven_Jenkins)\
**Post date:** [24 February 2004 22:01 UTC](https://rubytalk.org/t/rexml-performance/10295/2 "2004-02-24T22:01:07Z")

</div>

crazyfishpants wrote:

> I am using the Tree Parser in REXML. While parsing short documents  
> performance is great, performance is significantly impacted when  
> parsing large documents. Specifically, this occurs when the following  
> line is executed:

There was a longish thread on this topic earlier this month. The punch  
line is here:

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/91212](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/91212)

Steve

---

<div class="post-metadata">

**Author:** ![SER1](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@SER1](https://rubytalk.org/u/SER1)\
**Post date:** [25 February 2004 13:54 UTC](https://rubytalk.org/t/rexml-performance/10295/3 "2004-02-25T13:54:52Z")

</div>

“crazyfishpants” [scott.fisher@trans.ge.com](mailto:scott.fisher@trans.ge.com) wrote in message news:[c6f0d9b9c0e34a53830a96f69b3335ef@localhost.talkaboutprogramming.com](mailto:c6f0d9b9c0e34a53830a96f69b3335ef@localhost.talkaboutprogramming.com)…

> I am using the Tree Parser in REXML. While parsing short documents  
> performance is great, performance is significantly impacted when parsing  
> large documents. Specifically, this occurs when the following line is  
> executed:
> 
> xmlDoc = Document.new(File.new(fileToParse))
> 
> Any ideas?

Which version of REXML are you using? Recent versions had a speed  
degredation bug which has been fixed in the current version.

However, this won’t entirely fix your problem, since processing XML  
entirely in Ruby is always going to be relatively slow (compared to  
compiled languages, such as C or Java).

You can improve performance a little by using the Pull or SAX2  
parsers, but then you lose the tree functions. There is also a new,  
incomplete, undocumented light-weight tree API that you can play with  
that should be just a little slower than the Pull API (the fastest API  
in REXML).

— SER
