Skip to content

Instantly share code, notes, and snippets.

@maxpospischil
Last active February 29, 2016 20:19
Show Gist options
  • Save maxpospischil/c9279e0b3c012876f0cf to your computer and use it in GitHub Desktop.
Save maxpospischil/c9279e0b3c012876f0cf to your computer and use it in GitHub Desktop.
require 'net/http'
require 'securerandom'
t0 = Time.now
uri = URI.parse("http://a.com")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
puts "first call to net/http took this much time #{Time.now-t0}"
10.times do |i|
t0 = Time.now
uri = URI.parse("http://apple.com?rand=#{SecureRandom.hex}")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
res = http.request(request)
puts "call #{i}: #{Time.now-t0}"
end
10.times do |i|
t0 = Time.now
uri = URI.parse("http://google.com?rand=#{SecureRandom.hex}")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
res = http.request(request)
puts "call #{i}: #{Time.now-t0}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment