使用 CURL 测量网站响应时间

来源:网络 点击数: 发布时间:2021年12月09日

创建一个 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


time_namelookup DNS 解析时间。

time_connect 与 web server 建立 TCP 连接的时间。

time_appconnect 建立 TLS(安全传输层协议) 的时间。

time_starttransfer client 读到 server 返回的第一个字节的时间。

time_total client 关闭链接的时间。