Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获得所谓页面的响应时间:发送请求和第一个标头字节到来之间的时间?
PS:在这里我不想处理套接字 - 它可以工作,但它太原始了。
PPS:在 bash 中使用 curl 你可以这样做:
(time curl URL --head) 2>&1 | grep real | cut -c 6-
这应该可以帮助您:
from timeit import Timer from urllib2 import urlopen def fetch(): page = urlopen('http://www.google.com') return page.info() timer = Timer(fetch) print timer.timeit(1)