I have written the following code in ruby to ping a website and check the response. If the response comes true the website is responding well but if false that shows the website is not responding.
require 'net/http'
require 'uri'
def ping(host)
begin
url=URI.parse(host)
response=Net::HTTP.get(url)
if response==""
return false
else
return true
end
rescue Errno::ECONNREFUSED
return false
end
end
This code works fine but cannot calculate the respose time in which the website responds.
So my question is How to calculate the response time in which the website responds??