Sha256: deef5779de864159ef336ebe3bf5aa8ce46148e95a8c6feda5f681fb51d9f7ad

Contents?: true

Size: 1.97 KB

Versions: 15

Compression:

Stored size: 1.97 KB

Contents

$: << './benchmarks'
require 'server'

url = 'http://127.0.0.1/10k.html'

with_server do
  Tach.meter(100) do

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

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

    tach('em-http-request') do |n|
      EventMachine.run {
        count = 0
        error = 0
        n.times do
          EM.next_tick do
            http = EventMachine::HttpRequest.new(url, :connect_timeout => 1).get

            http.callback {
              count += 1
              if count == n
                p [count, error]
                EM.stop
              end
            }

            http.errback {
              count += 1
              error += 1
              if count == n
                p [count, error]
                EM.stop
              end
            }
          end
        end
      }
    end

    tach('em-http-request (persistent)') do |n|
      EventMachine.run {
        count = 0
        error = 0
        conn = EventMachine::HttpRequest.new(url)

        n.times do
          http = conn.get :keepalive => true
          http.callback {
            count += 1
            if count == n
              p [count, error]
              EM.stop
            end
          }

          http.errback {
            count += 1
            error += 1
            if count == n
              p [count, error]
              EM.stop
            end
          }
        end
      }
    end
  end
end

# +------------------------------+----------+
# | tach                         | total    |
# +------------------------------+----------+
# | em-http-request (persistent) | 0.018133 |
# +------------------------------+----------+
# | Excon (persistent)           | 0.023975 |
# +------------------------------+----------+
# | Excon                        | 0.032877 |
# +------------------------------+----------+
# | em-http-request              | 0.042891 |
# +------------------------------+----------+

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
em-http-request-samesite-0.1.1 benchmarks/em-excon.rb
em-http-request-samesite-1.1.7 benchmarks/em-excon.rb
em-http-request-1.1.7 benchmarks/em-excon.rb
em-http-request-1.1.6 benchmarks/em-excon.rb
em-http-request-1.1.5 benchmarks/em-excon.rb
em-http-request-1.1.4 benchmarks/em-excon.rb
em-http-request-1.1.3 benchmarks/em-excon.rb
em-http-request-1.1.2 benchmarks/em-excon.rb
em-http-request-1.1.1 benchmarks/em-excon.rb
em-http-request-1.1.0 benchmarks/em-excon.rb
em-http-request-1.0.3 benchmarks/em-excon.rb
em-http-request-1.0.2 benchmarks/em-excon.rb
em-http-request-1.0.1 benchmarks/em-excon.rb
em-http-request-1.0.0 benchmarks/em-excon.rb
em-http-request-1.0.0.beta.4 benchmarks/em-excon.rb