Sha256: 144ec63a004b11cd45d43e2561e49beef5d60cc9c7547925097ab54acb0b83e6

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'net/http'
require 'rest_client'
require 'curb'
require 'streamly'
require 'streamly_ffi'
require 'benchmark'

url = ARGV[0]

Benchmark.bmbm do |x|
  x.report do
    puts "StreamlyFFI"
    (ARGV[1] || 1).to_i.times do
      StreamlyFFI.get(url)
    end
  end

  x.report do
    puts "Streamly"
    (ARGV[1] || 1).to_i.times do
      Streamly.get(url)
    end
  end

  x.report do
    puts "Curb"
    (ARGV[1] || 1).to_i.times do
      Curl::Easy.perform(url)
    end
  end

  x.report do
    puts "`curl`"
    (ARGV[1] || 1).to_i.times do
      `curl -s --compressed #{url}`
    end
  end

  x.report do
    puts "rest-client"
    (ARGV[1] || 1).to_i.times do
      RestClient.get(url, {"Accept-Encoding" => "identity, deflate, gzip"})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
streamly_ffi-0.1.6 benchmark/basic_request.rb