2010-08-07 134 views

回答

1

你可以用插座做到這一點,就像這樣:

require "socket" 

# START MEASURING CONNECTION TIME 
connection = TCPSocket.open("example.com", 80) 
# END MEASURING CONNECTION TIME 

connection.print "GET/HTTP/1.1\r\nHost: example.com\r\n\r\n" 

# START MEASURING RESPONSE FETCHING TIME 
response = connection.read 
# END MEASURING RESPONSE FETCHING TIME 

connection.close