1、新建 curl-format 日志格式文件
echo -e "time_namelookup: %{time_namelookup}\\n\ntime_connect: %{time_connect}\\n\ntime_appconnect: %{time_appconnect}\\n\ntime_redirect: %{time_redirect}\\n\ntime_pretransfer: %{time_pretransfer}\\n\ntime_starttransfer: %{time_starttransfer}\\n\n----------\\n\ntime_total: %{time_total}\\n" > curl-format.txt
2、执行测试命令
curl -w "@curl-format.txt" -o /dev/null -s -L 'https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined?access_token=24.a895b1ecd00bfd8f5daa15d4c241fXXXXXXXXXXX8'
3、结果分析
[root@beichi webtest]# curl -w "@curl-format.txt" -o /dev/null -s -L 'https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined?access_token=24.a895b1ecd00bfd8f5daa15d4c241f845.2XXXXXXXXX'
time_namelookup: 0.000865
time_connect: 0.012962
time_appconnect: 0.046525
time_redirect: 0.000000
time_pretransfer: 0.046551
time_starttransfer: 0.127558
----------time_total: 0.127592
[root@beichi webtest]# curl -w "@curl-format.txt" -o /dev/null -s -L 'https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined?access_token=24.a895b1ecd00bfd8f5daa15d4c241f845.2592000.XXXXXXXXX'
time_namelookup: 0.385091
time_connect: 1.724289
time_appconnect: 5.432895
time_redirect: 0.000000
time_pretransfer: 5.432938
time_starttransfer: 10.123494
----------time_total: 10.123540
4、参数说明
time_namelookup: DNS 域名解的时候,就是把 https://zhihu.com 转换成 ip 地址的过程
time_connect: TCP 连接建立的时间,就是三次握手的时间
time_appconnect: SSL/SSH 等上层协议建立连接的时间,比如 connect/handshake 的时间
time_redirect: 从开始到最后一个请求事务的时间
time_pretransfer: 从请求开始到响应开始传输的时间
time_starttransfer: 从请求开始到第一个字节将要传输的时间
time total: 本次请求花费的总共时间