我想收集与 Web 请求的每个阶段需要多长时间相关的统计信息。httplib
提供:
def run(self): conn = httplib.HTTPConnection('www.example.com') start = time.time() conn.request('GET', '/') request_time = time.time() resp = conn.getresponse() response_time = time.time() conn.close() transfer_time = time.time() self.custom_timers['request sent'] = request_time - start self.custom_timers['response received'] = response_time - start self.custom_timers['content transferred'] = transfer_time - start assert (resp.status == 200), 'Bad Response: HTTP %s' % resp.status
这些统计信息是否可以从更高级别的界面(例如 )获得urllib2
?是否有提供此类统计数据的高级图书馆?