Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$ time curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 -I https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.4.0.tgz
# => real 0m0.117s
$ cat <<EOF | ruby
  require 'net/http'
  require 'benchmark'

  raw_time  = Benchmark.measure do
    url = URI('https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.4.0.tgz')

    response = nil
    Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
      response = http.head(url.path)
    end
    response.code.start_with?("20")
  end.real

  puts raw_time
EOF
# => 0.04965668899239972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment