How can I get a server response time with ruby?
Im using Net::HTTP.get_response(URI.parse(url))
to the response code and response time of the URL. Actually my code is:
start_time = Time.now
@req = Net::HTTP.get_response(URI.parse(url))
end_time = (Time.now - start_time) * 1000
puts ("%.2f" % end_time + "ms")
Is working perfectly, but I'm getting too high response times, e.g.: Twitter.com (630.52ms). If I try to ping twitter.com, I'm getting 70/120ms of response.
Is this the best way to calculate the response time of this server?