require "benchmark" require "yajl" require "json" BENCH_TIMES = 100000 hash = { s:"string", ss:["strings"] * 3, n:10, ns:(0..100).to_a.sample(20) } json = hash.to_json Benchmark.bmbm do |bm| bm.report("encode with yajl") do BENCH_TIMES.times do encoder = Yajl::Encoder.new encoder.encode(hash) end end bm.report("encode with yajl 2") do BENCH_TIMES.times do Yajl::Encoder.encode(hash) end end bm.repo