Sha256: b56cc2f7ba3b20cb95a4af288b740cd234eababb67b017e445da6657542a0d2a

Contents?: true

Size: 1.1 KB

Versions: 76

Compression:

Stored size: 1.1 KB

Contents

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'
require 'yajl'
begin
  require 'json'
rescue LoadError
end

# JSON section
filename = 'benchmark/subjects/ohai.json'
marshal_filename = 'benchmark/subjects/ohai.marshal_dump'
json = File.new(filename, 'r')
marshal_file = File.new(marshal_filename, 'r')

hash = {}

times = ARGV[0] ? ARGV[0].to_i : 1000
puts "Starting benchmark parsing #{File.size(filename)} bytes of JSON data #{times} times\n\n"
Benchmark.bmbm { |x|
  x.report {
    puts "Yajl::Parser#parse"
    yajl = Yajl::Parser.new
    yajl.on_parse_complete = lambda {|obj|} if times > 1
    times.times {
      json.rewind
      hash = yajl.parse(json)
    }
  }
  if defined?(JSON)
    x.report {
      puts "JSON.parse"
      times.times {
        json.rewind
        JSON.parse(json.read, :max_nesting => false)
      }
    }
  end
  x.report {
    puts "Marshal.load"
    times.times {
      marshal_file.rewind
      Marshal.load(marshal_file)
    }
  }
}
json.close
marshal_file.close

Version data entries

76 entries across 76 versions & 10 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_json_and_marshal.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_json_and_marshal.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_json_and_marshal.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_json_and_marshal.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/yajl-ruby-1.4.3/benchmark/parse_json_and_marshal.rb
yajl-ruby-1.4.3 benchmark/parse_json_and_marshal.rb
yajl-ruby-1.4.2 benchmark/parse_json_and_marshal.rb
yajl-ruby-1.4.1 benchmark/parse_json_and_marshal.rb
yajl-ruby-1.4.0 benchmark/parse_json_and_marshal.rb
yajl-ruby-1.2.3 benchmark/parse_json_and_marshal.rb
yajl-ruby-1.3.1 benchmark/parse_json_and_marshal.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/benchmark/parse_json_and_marshal.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/benchmark/parse_json_and_marshal.rb
yajl-ruby-1.2.2 benchmark/parse_json_and_marshal.rb
yajl-ruby-1.3.0 benchmark/parse_json_and_marshal.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/yajl-ruby-1.2.1/benchmark/parse_json_and_marshal.rb
ffi-yajl-2.2.0 lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
ffi-yajl-2.2.0-universal-java lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
ffi-yajl-2.1.0-universal-java lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
ffi-yajl-2.1.0 lib/ffi_yajl/benchmark/parse_json_and_marshal.rb