Last active
February 29, 2016 20:19
-
-
Save maxpospischil/c9279e0b3c012876f0cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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