-
-
Save kogent/139272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment