Sha256: 141ec3cd88e274618c77d97612891d0e008847dca16ca64071f89d12bd81cf56

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

# encoding: UTF-8
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.bm { |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

1 entries across 1 versions & 1 rubygems

Version Path
filipegiusti-yajl-ruby-0.6.4 benchmark/http.rb