Last active
August 29, 2015 14:11
-
-
Save deadkarma/63ef3be0e6598f414346 to your computer and use it in GitHub Desktop.
Multi-JSON vs JSON vs Messagepack
This file contains hidden or 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
require 'benchmark/ips' | |
require 'multi_json' | |
require 'json' | |
require 'msgpack' | |
hash = { | |
"site_config"=> | |
{ | |
"created_at"=>"2014-03-24T19:58:25Z", | |
"data"=>"", | |
"data_value"=>"1", | |
"group_id"=>nil, | |
"id"=>143, | |
"site_config_type_id"=>40500, | |
"site_id"=>1, | |
"updated_at"=>"2014-04-24T19:57:27Z", | |
"user_id"=>nil | |
} | |
} | |
Benchmark.ips do |x| | |
x.report('multi-json') { MultiJson.load(hash.to_json) } | |
x.report('json') { JSON.parse(hash.to_json) } | |
x.report('msgpack') { MessagePack.unpack(hash.to_msgpack) } | |
x.compare! | |
end |
Author
deadkarma
commented
Feb 27, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment