-
-
Save lipowen/2e97a448f87a50a82b8c957a87818166 to your computer and use it in GitHub Desktop.
Revisions
-
phiggins created this gist
Dec 1, 2010 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ $ 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 hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ 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 Empty file.