Sha256: f2ceb05c22eed1c23c0f85c4056f545cd54a42e8c250cb7a7d751c81ae43b923

Contents?: true

Size: 1.1 KB

Versions: 150

Compression:

Stored size: 1.1 KB

Contents

require 'rubygems' if RUBY_VERSION < '1.9'
require 'bundler'

Bundler.require(:default)
Bundler.require(:benchmark)

require 'sinatra/base'

require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'excon')

module Excon
  class Server < Sinatra::Base

    def self.run
      Rack::Handler::WEBrick.run(
        Excon::Server.new,
        :Port => 9292,
        :AccessLog => [],
        :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR)
      )
    end

    get '/data/:amount' do |amount|
      'x' * amount.to_i
    end

  end
end

def with_server(&block)
  pid = Process.fork do
    Excon::Server.run
  end
  loop do
    sleep(1)
    begin
      Excon.get('http://localhost:9292/api/foo')
      break
    rescue
    end
  end
  yield
ensure
  Process.kill(9, pid)
end

require 'tach'

size = 10_000
path = '/data/' << size.to_s
url = 'http://localhost:9292' << path

times = 1_000

with_server do

  Tach.meter(times) do

    tach('Excon') do
      Excon.get(url).body
    end

    excon = Excon.new(url)
    tach('Excon (persistent)') do
      excon.request(:method => 'get').body
    end

  end
end

Version data entries

150 entries across 148 versions & 6 rubygems

Version Path
excon-0.7.5 benchmarks/excon.rb
excon-0.7.4 benchmarks/excon.rb
excon-0.7.3 benchmarks/excon.rb
excon-0.7.2 benchmarks/excon.rb
excon-0.7.1 benchmarks/excon.rb
excon-0.7.0 benchmarks/excon.rb
excon-0.6.6 benchmarks/excon.rb
excon-0.6.5 benchmarks/excon.rb
excon-0.6.4 benchmarks/excon.rb
excon-0.6.3 benchmarks/excon.rb