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)