Why does REXML run significantly slower in Rails

We have some code that uses REXML, that when executed outside of Rails
as a
standalone rb file, runs fine. Once we run the code inside of Rails, it
dog slow. I know REXML is slow, buggy, sucks, etc., but my question is
cause the performance to degrade like that. Thanks.