Sha256: 3c9cdf611f0d483feae1d13fea0da5821124d947ea3d09a0064eb5cf021f57dd
Contents?: true
Size: 754 Bytes
Versions: 11
Compression:
Stored size: 754 Bytes
Contents
# encoding: UTF-8 require 'rubygems' require 'benchmark' require 'yajl_ext' require 'stringio' begin require 'json' rescue LoadError end times = ARGV[0] ? ARGV[0].to_i : 1000 filename = 'benchmark/subjects/ohai.json' json = File.new(filename, 'r') hash = Yajl::Parser.new.parse(json) json.close puts "Starting benchmark encoding #{filename} #{times} times\n\n" Benchmark.bmbm { |x| encoder = Yajl::Encoder.new x.report { puts "Yajl::Encoder#encode" times.times { encoder.encode(hash, StringIO.new) } } if defined?(JSON) x.report { puts "JSON's #to_json" times.times { JSON.generate(hash) } } end x.report { puts "Marshal.dump" times.times { Marshal.dump(hash) } } }
Version data entries
11 entries across 11 versions & 1 rubygems