【效率】【性能】接口响应时间(使用fiddler工具、pythton request的elapsed方法)

10 篇文章 0 订阅
1 篇文章 0 订阅

一、使用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.

翻译:

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值