curl 请求检测各阶段用时

2023-09-05 16:09:20 浏览数 (1)

curl

字段解析

NAMELOOKUP:从开始计算,域名解析完成的耗时

CURLINFO_NAMELOOKUP_TIME. The time it took from the start until the name resolving was completed.

CONNECT:从开始计算,TCP建立完成的耗时

CURLINFO_CONNECT_TIME. The time it took from the start until the connect to the remote host (or proxy) was completed.

APPCONNECT:从开始计算,应用层(SSL,在TCP之上的应用层)连接/握手完成的耗时

CURLINFO_APPCONNECT_TIME. The time it took from the start until the SSL connect/handshake with the remote host was completed. (Added in in 7.19.0)

PRETRANSFER:从开始计算,准备开始传输数据的耗时

CURLINFO_PRETRANSFER_TIME. The time it took from the start until the file transfer is just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.

STARTTRANSFER:从开始计算,开始传输数据的耗时(libcurl接收到第一个字节)

CURLINFO_STARTTRANSFER_TIME. The time it took from the start until the first byte is received by libcurl.

TOTAL:总的耗时

CURLINFO_TOTAL_TIME. Total time of the previous request.

REDIRECT:整个过程重定向的耗时,如果整个过程没有重定向,这个时间为0

CURLINFO_REDIRECT_TIME. The time it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. So, this is zero if no redirection took place.

命令使用

代码语言:javascript复制
curl -o /dev/null -s -w time_namelookup:"t"%{time_namelookup}"n"time_connect:"tt"%{time_connect}"n"time_appconnect:"t"%{time_appconnect}"n"time_pretransfer:"t"%{time_pretransfer}"n"time_starttransfer:"t"%{time_starttransfer}"n"time_total:"tt"%{time_total}"n"time_redirect:"tt"%{time_redirect}"n"  https://www.litblc.com

返回示例

代码语言:javascript复制
time_namelookup:0.000

time_connect:0.032

time_appconnect:0.000

time_pretransfer:0.032

time_starttransfer:0.780

time_total:0.844

time_redirect:0.000

注:这里的单位为秒

文档参考 https://curl.haxx.se/docs/httpscripting.html

0 人点赞