Created
December 1, 2010 06:02
-
-
Save phiggins/723047 to your computer and use it in GitHub Desktop.
excon benchmark vs google
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
$ ruby benchmarks/excon_vs_google.rb | |
[em-http-request, HTTParty, Net::HTTP, Net::HTTP (persistent), open-uri, RestClient, StreamlyFFI (persistent), Typhoeus, Excon, Excon (persistent)] | |
+--------------------------+-----------+ | |
| tach | total | | |
+--------------------------+-----------+ | |
| Excon | 7.614298 | | |
+--------------------------+-----------+ | |
| Typhoeus | 7.723362 | | |
+--------------------------+-----------+ | |
| StreamlyFFI (persistent) | 7.778743 | | |
+--------------------------+-----------+ | |
| Excon (persistent) | 8.178862 | | |
+--------------------------+-----------+ | |
| open-uri | 17.996636 | | |
+--------------------------+-----------+ | |
| RestClient | 18.041814 | | |
+--------------------------+-----------+ | |
| Net::HTTP | 18.256657 | | |
+--------------------------+-----------+ | |
| Net::HTTP (persistent) | 18.293269 | | |
+--------------------------+-----------+ | |
| em-http-request | 18.554890 | | |
+--------------------------+-----------+ | |
| HTTParty | 18.624778 | | |
+--------------------------+-----------+ |
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' if RUBY_VERSION < '1.9' | |
require 'bundler' | |
Bundler.require(:default) | |
Bundler.require(:benchmark) | |
require File.join(File.dirname(__FILE__), '..', 'lib', 'excon') | |
require 'em-http-request' | |
require 'httparty' | |
require 'net/http' | |
require 'open-uri' | |
require 'rest_client' | |
require 'tach' | |
require 'typhoeus' | |
url = "http://www.google.com" | |
Tach.meter(100) do | |
tach('em-http-request') do | |
EventMachine.run { | |
http = EventMachine::HttpRequest.new(url).get | |
http.callback { | |
http.response | |
EventMachine.stop | |
} | |
} | |
end | |
tach('HTTParty') do | |
HTTParty.get(url).body | |
end | |
tach('Net::HTTP') do | |
# Net::HTTP.get('localhost', '/data/1000', 9292) | |
Net::HTTP.start('www.google.com', 80) {|http| http.get('/').body } | |
end | |
Net::HTTP.start('www.google.com', 80) do |http| | |
tach('Net::HTTP (persistent)') do | |
http.get('/').body | |
end | |
end | |
tach('open-uri') do | |
open(url).read | |
end | |
tach('RestClient') do | |
RestClient.get(url) | |
end | |
streamly = StreamlyFFI::Connection.new | |
tach('StreamlyFFI (persistent)') do | |
streamly.get(url) | |
end | |
tach('Typhoeus') do | |
Typhoeus::Request.get(url).body | |
end | |
tach('Excon') do | |
Excon.get(url).body | |
end | |
excon = Excon.new(url) | |
tach('Excon (persistent)') do | |
excon.request(:method => 'get').body | |
end | |
end |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment