Sha256: 24fe151aafa02d0cf678b7e0463e1639c792650a6dcad7737757e167ff1208c4
Contents?: true
Size: 810 Bytes
Versions: 2
Compression:
Stored size: 810 Bytes
Contents
# encoding: UTF-8 require 'rubygems' require 'benchmark' require 'yajl' require 'json' require 'activesupport' filename = ARGV[0] || 'benchmark/subjects/twitter_search.json' json = File.new(filename, 'r') # warm up the filesystem json.read json.rewind times = ARGV[1] ? ARGV[1].to_i : 1 puts "Starting benchmark parsing #{File.size(filename)} bytes of JSON data #{times} times\n\n" Benchmark.bm { |x| x.report { puts "Yajl::Stream.parse" times.times { json.rewind Yajl::Stream.parse(json) } } x.report { puts "JSON.parser" times.times { json.rewind JSON.parse(json.read, :max_nesting => false) } } x.report { puts "ActiveSupport::JSON.decode" times.times { json.rewind ActiveSupport::JSON.decode(json.read) } } } json.close
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brianmario-yajl-ruby-0.4.5 | benchmark/parse.rb |
brianmario-yajl-ruby-0.4.6 | benchmark/parse.rb |