Created
March 9, 2012 11:38
-
-
Save andyjeffries/2006182 to your computer and use it in GitHub Desktop.
messagepack vs yajl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11:34 ~ $ irb | |
1.9.2p290 :001 > require 'rubygems' | |
=> false | |
1.9.2p290 :002 > require 'json' | |
=> true | |
1.9.2p290 :003 > require 'msgpack' | |
=> true | |
1.9.2p290 :004 > f = File.read('test.json'); nil # f is our calendar data | |
=> nil | |
1.9.2p290 :005 > h = JSON.parse(f); nil | |
=> nil | |
1.9.2p290 :007 > m = MessagePack.pack(h); nil | |
=> nil | |
1.9.2p290 :009 > require 'yajl' | |
=> true | |
# Time in millseconds to decode each | |
1.9.2p290 :010 > a = Time.now; h = Yajl::Parser.new.parse(f); nil; (Time.now-a)*1000 | |
=> 144.823 | |
1.9.2p290 :011 > a = Time.now; h = MessagePack.unpack(m); nil; (Time.now-a)*1000 | |
=> 53.449000000000005 | |
# Smaller uncompressed | |
1.9.2p290 :012 > m.size | |
=> 2351616 | |
1.9.2p290 :013 > f.size | |
=> 4542940 | |
# Smaller compressed | |
1.9.2p290 :016 > ActiveSupport::Gzip.compress(m).size | |
=> 135666 | |
1.9.2p290 :017 > ActiveSupport::Gzip.compress(f).size | |
=> 165177 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment