No description or website provided.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Serialisation Format Benchmark

This is a simple script to benchmark the serialisation of various formats. Although each format claims to be the fastest, how do I know which is true and which is lying?


I want to know the most efficient way to transfer data between two applications. The intended use is on a Rails webserver, so I'll assume the important bits are serialisation time, deserialisation time and lesser the size of the serialised object. I wanted to a realistic benchmark, that uses real data, so I took some data from Tweeted Links.

I choose to benchmark the following, as they are all supported by RABL:

  • JSON
  • YAJL
  • MessagePack
  • BSON

Running the benchmark

You need git, ruby and bundler:

git clone git://
cd serialisation_benchmark
ruby benchmark.rb

I highly encourage you to ruby the benchmark yourself (also running bundle update before hand) on your own system to see what you get. The output for encoding and decoding is requests per second, and the size is in bytes.


Here are the results on my machine, a 1.6 Ghz Core i5 running OS X 10.7.4:

‹ruby-1.9.3›  $ ruby benchmark.rb 
JSON encode: 1649
JSON size: 15968
JSON decode: 1039

YAJL encode: 2428
YAJL size: 15968
YAJL decode: 1323

BSON encode: 2922
BSON size: 16531
BSON decode: 506

MessagePack encode: 5186
MessagePack size: 14127
MessagePack decode: 2085