Sha256: 8b56e656c67830b53ae3873c09e667362085faeefa3f06f2ec9594ef0ddb766a

Contents?: true

Size: 1.2 KB

Versions: 76

Compression:

Stored size: 1.2 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
begin
  require 'active_support'
rescue LoadError
end

filename = 'benchmark/subjects/twitter_stream.json'
json = File.new(filename, 'r')

times = ARGV[0] ? ARGV[0].to_i : 100
puts "Starting benchmark parsing JSON stream (#{File.size(filename)} bytes of JSON data with 430 JSON separate strings) #{times} times\n\n"
Benchmark.bmbm { |x|
  parser = Yajl::Parser.new
  parser.on_parse_complete = lambda {|obj|}
  x.report {
    puts "Yajl::Parser#parse"
    times.times {
      json.rewind
      parser.parse(json)
    }
  }
  if defined?(JSON)
    x.report {
      puts "JSON.parse"
      times.times {
        json.rewind
        while chunk = json.gets
          JSON.parse(chunk, :max_nesting => false)
        end
      }
    }
  end
  if defined?(ActiveSupport::JSON)
    x.report {
      puts "ActiveSupport::JSON.decode"
      times.times {
        json.rewind
        while chunk = json.gets
          ActiveSupport::JSON.decode(chunk)
        end
      }
    }
  end
}
json.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_stream.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_stream.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_stream.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/benchmark/parse_stream.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/yajl-ruby-1.4.3/benchmark/parse_stream.rb
yajl-ruby-1.4.3 benchmark/parse_stream.rb
yajl-ruby-1.4.2 benchmark/parse_stream.rb
yajl-ruby-1.4.1 benchmark/parse_stream.rb
yajl-ruby-1.4.0 benchmark/parse_stream.rb
yajl-ruby-1.2.3 benchmark/parse_stream.rb
yajl-ruby-1.3.1 benchmark/parse_stream.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/benchmark/parse_stream.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/benchmark/parse_stream.rb
yajl-ruby-1.2.2 benchmark/parse_stream.rb
yajl-ruby-1.3.0 benchmark/parse_stream.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/yajl-ruby-1.2.1/benchmark/parse_stream.rb
ffi-yajl-2.2.0 lib/ffi_yajl/benchmark/parse_stream.rb
ffi-yajl-2.2.0-universal-java lib/ffi_yajl/benchmark/parse_stream.rb
ffi-yajl-2.1.0-universal-java lib/ffi_yajl/benchmark/parse_stream.rb
ffi-yajl-2.1.0 lib/ffi_yajl/benchmark/parse_stream.rb