Sha256: 86c8863c81f61a01d62e113731871d092b0f9ccd4ad2921d468b151e498fdd6f

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

# 
# The original version of this benchmark can be found at :
# 
#     http://m.onkey.org/2008/2/2/tidbits-from-my-crap
#
# By running it, you'll simply learn that rufus-verbs perform like
# net/http which it wraps.
# Seems a bit better than open-uri though.
#
# Mon Feb 18 09:17:02 JST 2008
# 

#['rubygems', 'benchmark', 'eventmachine', 'net/http', 'open-uri', 'rfuzz/session'].each {|lib| require lib }
['rubygems', 'benchmark', 'net/http', 'open-uri', 'rufus/verbs' ].each {|lib| require lib }

server      = 'tiramisu'
port        = 80
request_uri = "http://#{server}:#{port}/"

def run(name, x)
  x.report(name) do
    100.times do
      yield
    end
  end
end

uri = URI.parse(request_uri)
puts Net::HTTP.get(uri)

#rfuzz = RFuzz::HttpClient.new(server, port)
#puts rfuzz.get('/').http_body

puts open(request_uri).read

#puts Rufus::Verbs.get(uri)
puts Rufus::Verbs.get(request_uri)

#EM.epoll
#http = nil
#EM.run do
#  http = EM::Protocols::HttpClient2.connect(server, port).get("/")
#  http.callback { EM.stop  }
#end
#puts http.content
#EM.run { EM::Protocols::HttpClient2.connect(server, port).get("/").callback { EM.stop  } }

Benchmark.bm do |x|
  
  run("Ruby Net::HTTP ", x) do
    Net::HTTP.get(uri)
  end
  
  run("Open URI       ", x) do
    open(request_uri).read
  end

  run("Rufus-verbs    ", x) do
    #Rufus::Verbs.get(uri)
    Rufus::Verbs.get(request_uri)
  end
  
  #run("RFuzz          ", x) do
  #  rfuzz.get('/').http_body
  #end
  
  #run("Event Machine  ", x) do
  #  EM.run { EM::Protocols::HttpClient2.connect(server, port).get("/").callback {  EM.stop } }
  #end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rufus-verbs-1.0.1 test/bm.rb
rufus-verbs-1.0.0 test/bm.rb
rufus-verbs-0.10 test/bm.rb
rufus-verbs-0.8 test/bm.rb
rufus-verbs-0.9 test/bm.rb