Skip to content

Instantly share code, notes, and snippets.

@schneems
Created September 30, 2019 16:55
Show Gist options
  • Save schneems/4a9ac56faf87cf2ff93cab139f912334 to your computer and use it in GitHub Desktop.
Save schneems/4a9ac56faf87cf2ff93cab139f912334 to your computer and use it in GitHub Desktop.
$ 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