Created
September 15, 2011 11:15
-
-
Save kaiwren/1219023 to your computer and use it in GitHub Desktop.
Json gem vs. Json pure
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
require 'rubygems' | |
require 'multi_json' | |
require 'benchmark' | |
n = 100000 | |
json = "{\"ids_shop\":[],\"ids_collection\":[],\"ids_wish_list\":[]}" | |
Benchmark.bmbm do |x| | |
# x.report("json") do | |
# MultiJson.engine = :json_gem | |
# n.times { MultiJson.decode(json) } | |
# end | |
x.report("json pure") do | |
MultiJson.engine = :json_pure | |
n.times { MultiJson.decode(json) } | |
end | |
end | |
# Rehearsal --------------------------------------------- | |
# json pure 5.260000 0.010000 5.270000 ( 5.267665) | |
# ------------------------------------ total: 5.270000sec | |
# | |
# user system total real | |
# json pure 5.300000 0.020000 5.320000 ( 5.308652) | |
# Rehearsal ---------------------------------------- | |
# json 0.760000 0.020000 0.780000 ( 0.786621) | |
# ------------------------------- total: 0.780000sec | |
# | |
# user system total real | |
# json 0.750000 0.030000 0.780000 ( 0.770398) | |
# copy output | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment