Sha256: 4be4b0440b41a9ec3fbaa51317c297a66ad16b4debcc6d42d01037d9d18d8af2
Contents?: true
Size: 1021 Bytes
Versions: 24
Compression:
Stored size: 1021 Bytes
Contents
# encoding: UTF-8 require 'rubygems' require 'benchmark' require 'yajl_ext' require 'json' require 'activesupport' filename = ARGV[0] || 'benchmark/subjects/ohai.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| io_parser = Yajl::Parser.new x.report { puts "Yajl::Parser#parse (from an IO)" times.times { json.rewind io_parser.parse(json) } } string_parser = Yajl::Parser.new x.report { puts "Yajl::Parser#parse (from a String)" times.times { json.rewind string_parser.parse(json.read) } } x.report { puts "JSON.parse" 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
24 entries across 24 versions & 5 rubygems