benchmark/encode.rb in yajl-ruby-0.6.3 vs benchmark/encode.rb in yajl-ruby-0.6.4

- old
+ new

@@ -10,13 +10,13 @@ filename = ARGV[0] || 'benchmark/subjects/ohai.json' json = File.new(filename, 'r') hash = Yajl::Parser.new.parse(json) json.close -times = ARGV[1] ? ARGV[1].to_i : 1 +times = ARGV[1] ? ARGV[1].to_i : 1000 puts "Starting benchmark encoding #{filename} #{times} times\n\n" -Benchmark.bm { |x| +Benchmark.bmbm { |x| io_encoder = Yajl::Encoder.new x.report { puts "Yajl::Encoder#encode (to an IO)" times.times { io_encoder.encode(hash, StringIO.new) @@ -28,10 +28,10 @@ times.times { output = string_encoder.encode(hash) } } x.report { - puts "JSON's #to_json" + puts "JSON.generate" times.times { JSON.generate(hash) } } # Can't use ActiveSuport::JSON.encode with the JSON gem loaded