Created
February 4, 2009 05:26
-
-
Save arunthampi/57963 to your computer and use it in GitHub Desktop.
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 'rubygems' | |
require 'json' | |
require 'benchmark' | |
# all_dbs.js > Output from CouchDBs http://127.0.0.1:5984/_all_dbs | |
# Simple array of strings | |
js = File.read('all_dbs.js') | |
# sg.js > Internal API for hotels in a city (Singapore) | |
# Slightly more complicated nested data structures including strings and numbers and arrays and hashes | |
sg = File.read('sg.js') | |
Benchmark.bm do |x| | |
x.report("simple json:") { JSON.parse(js) } | |
x.report("slightly complicated json:") { JSON.parse(sg) } | |
end | |
Results: | |
* 1.9.1-p0 | |
arun:~/ruby/json_benchmark$ ~/.multiruby/install/1.9.1-p0/bin/ruby json_parser.rb | |
user system total real | |
simple json: 13.060000 0.310000 13.370000 ( 13.384820) | |
slightly complicated json: 18.420000 0.110000 18.530000 ( 18.556238) | |
* 1.8.7 | |
arun:~/ruby/json_benchmark$ ruby json_parser.rb | |
user system total real | |
simple json: 13.290000 0.330000 13.620000 ( 13.759942) | |
slightly complicated json: 16.170000 0.080000 16.250000 ( 16.356992) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment