I have a large-ish array (~400 elements) of ActiveRecord objects that I need to convert to XML. I've used array.to_xml
for convenience, but it's very slow -- about 20 seconds when the server is busy, and about 5 seconds when idle.
I've just run a few benchmarks while the server was idle, and found that:
- the ActiveRecord query (complete with two-level :include) takes about 0.3s on average.
- converting that result set to XML takes about 4.9s on average. 4.86s of that is User CPU time.
Is there a drop-in replacement for Builder::XmlMarkup that will improve the speed of to_xml? Or will I have to hand-roll something?