public
Last active — forked from lifo/bench.rb

  • Download Gist
bench.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
require 'rubygems'
require 'curb'
require "net/http"
require 'benchmark'
 
# http://0.0.0.0:8080
#
# class HomeController < ApplicationController
# def index
# sleep 3
# end
# end
 
# [lifo@null curb (master)]£ ruby bench.rb
# Curl::Multi 3.01691508293152
# Net::HTTP 15.0276219844818
 
responses = {}
curb = Benchmark.realtime do
m = Curl::Multi.new
 
5.times do |i|
responses[i] = ""
 
c = Curl::Easy.new('http://0.0.0.0:8080') do |curl|
curl.follow_location = false
curl.on_body{|data| responses[i] << data; data.size }
end
m.add(c)
end
 
m.perform
end
 
puts "Curl::Multi #{curb}"
 
nh = Benchmark.realtime do
5.times do
http = Net::HTTP.start('0.0.0.0', 8080)
res = http.request(Net::HTTP::Get.new("/"))
end
end
 
puts "Net::HTTP #{nh}"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.