on-internet
← Community

Getting TTFB (time till first byte) for an HTTP Request

Stack Overflow ·

Here is a python script that loads a url and captures response time: import urllib2 import time opener = urllib2.build_opener() request = urllib2.Request('http://example.com') start = time.time() resp = opener.open(request) resp.read() ttlb = time.time() - start Since my timer is wrapped around the whole request/response (including read()), this will give me the TTLB (time to last byte). I would also like to get the TTFB (time to first byte), but am not sure where to start/stop my timing. Is urllib2 granular enough for me to add TTFB timers? If so, where would they go?

Comments

Sign in or sign up to comment and upvote.

No comments yet.