Sha256: 3701ff12654322920669180589281bf087b70b03a61588373c1b143f3b6d932e

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

require 'rubygems'
require 'benchmark'
require 'builder'
require 'json_builder'

Benchmark.bm do |b|
  b.report('JSONBuilder') do
    15_000.times {
      JSONBuilder::Compiler.generate {
        name "Garrett Bjerkhoel"
        birthday Time.local(1991, 9, 14)
        street do
          address "1143 1st Ave"
          address2 "Apt 200"
          city "New York"
          state "New York"
          zip 10065
        end
        skills do
          ruby true
          asp false
          php true
          mysql true
          mongodb true
          haproxy true
          marathon false
        end
        single_skills ['ruby', 'php', 'mysql', 'mongodb', 'haproxy']
        booleans [true, true, false, nil] 
      }
    }
  end
  b.report('Builder') do
    15_000.times {
      xml = Builder::XmlMarkup.new(:indent => 2)
      xml.name "Garrett Bjerkhoel"
      xml.birthday Time.local(1991, 9, 14)
      xml.street do
        xml.address "1143 1st Ave"
        xml.address2 "Apt 200"
        xml.city "New York"
        xml.state "New York"
        xml.zip 10065
      end
      xml.skills do
        xml.ruby true
        xml.asp false
        xml.php true
        xml.mysql true
        xml.mongodb true
        xml.haproxy true
        xml.marathon false
      end
      xml.single_skills ['ruby', 'php', 'mysql', 'mongodb', 'haproxy']
      xml.booleans [true, true, false, nil]
      xml.target!
    }
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
json_builder-3.1.7 test/benchmarks/builder.rb
json_builder-3.1.6 test/benchmarks/builder.rb
json_builder-3.1.5 test/benchmarks/builder.rb
json_builder-3.1.4 test/benchmarks/builder.rb
json_builder-3.1.3 test/benchmarks/builder.rb
json_builder-3.1.2 test/benchmarks/builder.rb
json_builder-3.1.1 test/benchmarks/builder.rb
json_builder-3.1.0 test/benchmarks/builder.rb
json_builder-3.0.7 test/benchmarks/builder.rb
json_builder-3.0.6 spec/benchmarks/builder.rb
json_builder-3.0.4 spec/benchmarks/builder.rb
json_builder-3.0.3 spec/benchmarks/builder.rb
json_builder-3.0.2 spec/benchmarks/builder.rb
json_builder-3.0.1 spec/benchmarks/builder.rb