Sha256: 5eb3e53d65501d0029aa56557a2b8de860f50c8a57d0a3bc2222e44e948ee814
Contents?: true
Size: 682 Bytes
Versions: 24
Compression:
Stored size: 682 Bytes
Contents
# encoding: UTF-8 require 'rubygems' require 'benchmark' require 'yajl_ext' require 'stringio' require 'json' times = ARGV[0] ? ARGV[0].to_i : 1 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.bm { |x| encoder = Yajl::Encoder.new x.report { puts "Yajl::Encoder#encode" times.times { encoder.encode(hash, StringIO.new) } } x.report { puts "JSON's #to_json" times.times { JSON.generate(hash) } } x.report { puts "Marshal.dump" times.times { Marshal.dump(hash) } } }
Version data entries
24 entries across 24 versions & 5 rubygems