Sha256: 68f2194c2cea1664283a952709328cf415b05d66e13110dce078f9df21e248c3

Contents?: true

Size: 842 Bytes

Versions: 4

Compression:

Stored size: 842 Bytes

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/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} #{times} times\n\n"
Benchmark.bmbm do |x|
  x.report do
    puts "Yajl::HttpStream.get"
    times.times { Yajl::HttpStream.get(uri) }
  end
  x.report do
    puts "JSON.parser"
    times.times { JSON.parse(Net::HTTP.get_response(uri).body, max_nesting: false) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ffi-yajl-2.3.3 lib/ffi_yajl/benchmark/http.rb
ffi-yajl-2.3.3-universal-java lib/ffi_yajl/benchmark/http.rb
ffi-yajl-2.3.1-universal-java lib/ffi_yajl/benchmark/http.rb
ffi-yajl-2.3.1 lib/ffi_yajl/benchmark/http.rb