Sha256: 50c343a07010120bc5645c8d4ea949d22495c8e145598afd83e9d40449a62c2d

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')

require 'rubygems'
require 'benchmark'
require 'yajl/http_stream'
require 'yajl/gzip'
require 'yajl/deflate'
require 'yajl/bzip2' unless defined?(Bzip2)
require 'json'
require 'uri'
require 'net/http'

uri = URI.parse('http://search.twitter.com/search.json?q=github')
# uri = URI.parse('http://localhost/yajl-ruby.git/benchmark/subjects/contacts.json')

times = ARGV[0] ? ARGV[0].to_i : 1
puts "Starting benchmark parsing #{uri.to_s} #{times} times\n\n"
Benchmark.bmbm { |x|
  x.report {
    puts "Yajl::HttpStream.get"
    times.times {
      Yajl::HttpStream.get(uri)
    }
  }
  x.report {
    puts "JSON.parser"
    times.times {
      JSON.parse(Net::HTTP.get_response(uri).body, :max_nesting => false)
    }
  }
}

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
yajl-ruby-0.7.8 benchmark/http.rb
yajl-ruby-0.7.7 benchmark/http.rb
benofsky-yajl-ruby-0.7.7 benchmark/http.rb
benofsky-yajl-ruby-0.7.6 benchmark/http.rb