After intensive testing of YAML, Marshal and JSON serialization (all available and tested in the gem), we have decided to use JSON because it’s the fastest solution in real-world cases and it’s less problematic on the long run.
In case you have read that Marshal is faster then JSON, this might be the case if:
- you don’t read (decode) more often then you encode (not the case in a web app)
- the tests don’t include the ‘pack’ and ‘unpack’ necessary to move the data in the database
My own benchmarks show:
user system total real JSON 0.710000 0.010000 0.720000 ( 0.720144) Marshal 0.830000 0.050000 0.880000 ( 0.888717)
You can download the “testfile” if you want.
PS: In fact, Marshal is faster if you encode lots of tiny objects, but there are many disadvantages to using Marshal encoding that the tiny speed difference is just not worth it.