cURL 是一个优秀的web请求工具,它还具有测量请求时间的能力。
实践
创建一个 curl 的配置文件:
$ vi ~/.curlrc
# 内容(较长,可以左右滑动)
-w "dnslookup: %{time_namelookup} | connect: %{time_connect} \n appconnect: %{time_appconnect} \n pretransfer: %{time_pretransfer} \n starttransfer: %{time_starttransfer} \n total: %{time_total} | size: %{size_download}\n"
使用:
$ curl -so /dev/null https://www.zasag.mn
# 输出
dnslookup: 1.510
connect: 1.757
appconnect: 2.256
pretransfer: 2.259
starttransfer: 2.506
total: 3.001
size: 53107
解析
下面看一下各个时间的含义:
通过这几个时间点,我们就可以方便的知道请求过程的细节,找到主要性能点。
内容整理自:https://blog.cloudflare.com/a-question-of-timing/,其中还有 chrome 的测量方式,有兴趣的朋友可以看一下。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有