3 ms·
If you want json to be fast in Ruby, chances are you might want to look at https://github.com/ohler55/oj https://github.com/ohler55/oj Not sure how easy it is
by rb2k_ 12y ago
If you want json to be fast in Ruby, chances are you might want to look at https://github.com/ohler55/oj https://github.com/ohler55/oj
Not sure how easy it is to jam oj into either of these two serializers though.
EDIT: rabl seems to support it according to the webpage
- bretthopper 12y agoThese benchmarks are already using OJ: https://github.com/thuva/json_serialization_benchmark/blob/master/Gemfile#L4 https://github.com/thuva/json_serialization_benchmark/blob/m... edit: although not sure it's being used properly yet
- mrinterweb 12y agoI forked and fixed the ActiveModel::Serializer and presenter examples to us Oj with MultiJson. I was unable to get rabl to work with the Oj engine for some reason. I didn't feel like spending any extra time to track it down. Anyway, from the benchmark, I was seeing that the Oj json serializer was approximately 3-10x faster than the normal to_json method. https://github.com/mrinterweb/json_serialization_benchmark https://github.com/mrinterweb/json_serialization_benchmark
- ttharma 12y agoIncluding Oj in Gemfile and not using it properly has caused some confusion. The original purpose of the benchmark was to test the relative performance of RABL, AMS, and presenters. In that case, the choice of the JSON library should not matter. Having said that, it would still be nice to see the best performance we can get out of the 3 tools we're benchmarking. But, we need to get Oj working with all 3 of them in order to avoid unfair comparison of performance.
- zimbatm 12y agoMake sure to never send Symbol objects to Oj, it will serialize them as ":foo". All other JSON libraries will represent them as "foo". And if you need to traverse your object graph to call #to_s on the symbols then the performance gain of Oj is lost.