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 is dog slow. I know REXML is slow, buggy, sucks, etc., but my question is what cause the performance to degrade like that. Thanks.