Skip to content

Instantly share code, notes, and snippets.

@cyx
Created October 22, 2013 20:57
Show Gist options
  • Save cyx/7108019 to your computer and use it in GitHub Desktop.
Save cyx/7108019 to your computer and use it in GitHub Desktop.
require "benchmark"
require "msgpack"
require "json"
N = Integer(ARGV[0] || 10000)
data = { 'hello' => { 'there' => 'peeps' },
'yes' => [1, 2, 3],
'no' => true, 'bam' => false }
Benchmark.bmbm do |x|
x.report "msgpack" do
N.times do
data.to_msgpack
end
end
x.report "json" do
N.times do
data.to_json
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment