Sha256: e9fb93be2df80f79a828edb78235078791a818879ef7b9a7cba978f4b01cd1fa

Contents?: true

Size: 1022 Bytes

Versions: 98

Compression:

Stored size: 1022 Bytes

Contents

#!/usr/bin/env ruby

require 'bullshit'
$KCODE='utf8'
if ARGV.shift == 'pure'
  require 'json/pure'
else
  require 'json/ext'
end

class BC_Generator < Bullshit::TimeCase
  include JSON

  warmup    true
  duration  10

  def setup
    a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
    puts JSON[a]
    @big = a * 100
  end

  def benchmark_generator_fast
    @result = JSON.fast_generate(@big)
  end

  def reset_benchmark_generator_fast
    @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
  end

  def benchmark_generator_safe
    @result = JSON.generate(@big)
  end

  def reset_benchmark_generator_safe
    @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
  end

  def benchmark_generator_pretty
    @result = JSON.pretty_generate(@big)
  end

  def reset_benchmark_generator_pretty
    @result and @result.size > 2 + 6 * @big.size or raise @result.to_s
  end

  compare :generator_fast, :generator_safe, :generator_pretty
end

Version data entries

98 entries across 92 versions & 14 rubygems

Version Path
relevance-castronaut-0.5.2 vendor/json/benchmarks/benchmark_generator.rb
relevance-castronaut-0.5.3 vendor/json/benchmarks/benchmark_generator.rb
relevance-castronaut-0.5.4 vendor/json/benchmarks/benchmark_generator.rb
relevance-castronaut-0.6.0 vendor/json/benchmarks/benchmark_generator.rb
relevance-castronaut-0.6.1 vendor/json/benchmarks/benchmark_generator.rb
relevance-castronaut-0.7.4 vendor/json/benchmarks/benchmark_generator.rb
relevance-castronaut-0.7.5 vendor/json/benchmarks/benchmark_generator.rb
nbudin-castronaut-0.7.5 vendor/json/benchmarks/benchmark_generator.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
merb-core-1.1.3 spec10/public/core_ext/fixtures/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
merb-core-1.1.2 spec10/public/core_ext/fixtures/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
merb-core-1.1.1 spec10/public/core_ext/fixtures/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
poolparty-1.6.9 vendor/gems/json/benchmarks/benchmark_generator.rb
poolparty-1.6.8 vendor/gems/json/benchmarks/benchmark_generator.rb
poolparty-1.6.7 vendor/gems/json/benchmarks/benchmark_generator.rb
poolparty-1.6.6 vendor/gems/json/benchmarks/benchmark_generator.rb
merb-core-1.1.0 spec10/public/core_ext/fixtures/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/json_pure-1.1.3/benchmarks/benchmark_generator.rb