I've been doing some benchmarks on how fast ActiveRecord's #to_xml is
on large datasets, versus the speed of A
ActiveRecord's #to_json, and the difference is rather alarming.
#to_xml becomes quickly unusable for large datasets, while to_json
The important thing here isn't how fast #to_json is -- it's that you
can't practically use #to_xml anymore after a certain point, a low
Some basic benchmarks, with a User model that has 5 fields: an
integer, a string, a text, and two datetimes.
to_xml - "User.find(:all).to_xml"
to_json - "User.find(:all).to_json"
to_xml - ~0.20 seconds
to_json - ~0.02 seconds
to_xml - ~6.9 seconds
to_json - ~0.4 seconds
to_xml - ~25 seconds
to_json - ~0.9 seconds
to_xml - >10 minutes (didn't wait for it finish)
to_json - 10.7 seconds
Can anybody comment on this? With Rails pushing ActiveResource and
REST like crazy, services which really start allowing people to list
their products and userbases in XML are going to have a tough time
with out-of-the-box Rails, with performance like this.