一、使用fiddler工具查看接口响应时间
测试项:http接口响应时间
测试工具:fiddler
查看方法:
(1)选中单条URL,在右侧的视图中选择statistics->overalll elapsed 的值为接口响应时间

(2)设置把此字段列出来的方法:
在URL那一栏右键点击,选择customize columns,然后在弹框中选择session timers、overall_elapsed

点击add,添加成功后,效果如下:

通过监控此响应时间,比如发现一个接口响应时间超过5S,设置超过10S了,可暴露出具体哪个接口慢,通过优化接口的响应时间提升产品的性能,用户体验(对应的质量指标是效率)。
二、python+request查看接口响应时间
#encoding:utf-8
import requests
import logging
logging.basicConfig(level=logging.NOTSET)
url="http://cn.python-requests.org/zh_CN/latest/"
r = requests.get(url)
logging.info("begin")
s=r.elapsed.total_seconds()
logging.info("%s接口响应时间:%s",url,s)
logging.info("finish")

elapsed方法的官方文档地址:http://cn.python-requests.org/zh_CN/latest/api.html#requests.Response
elapsed = None
The amount of time elapsed between sending the request and the arrival of the response (as a timedelta). This property specifically measures the time taken between sending the first byte of the request and finishing parsing the headers. It is therefore unaffected by consuming the response content or the value of the stream keyword argument.
翻译:

本文介绍如何使用Fiddler工具及Python+requests库监测HTTP接口的响应时间,通过具体操作步骤和代码示例,帮助读者掌握接口性能测试技巧。
2362

被折叠的 条评论
为什么被折叠?



