curl 时间变量格式化输出
获取站点的各类响应时间,可以去看看前面写的文章。
对curl时间变量的格式化输出。
定义格式化文件
#vim curl-format.txt
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n这些变量的含义不解释了,大伙去看看curl帮助文档。重点说下time_connect和time_appconnect变量。time_connect 变量表示 TCP 握手的耗时,time_appconnect 变量表示 SSL 握手的耗时(ssl延时)。HTTPs 连接耗时要比 HTTP 连接耗时长 3 倍左右,具体取决于 CPU 的快慢。
发送请求
# curl -w "@curl-format.txt" -o /dev/null -s http://www.baidu.com
time_namelookup: 0.002
time_connect: 1.973
time_appconnect: 0.000
time_pretransfer: 1.973
time_redirect: 0.000
time_starttransfer: 3.126
----------
time_total: 5.374
# curl -w "@curl-format.txt" -o /dev/null -s https://www.baidu.com
time_namelookup: 0.003
time_connect: 1.705
time_appconnect: 4.007
time_pretransfer: 4.007
time_redirect: 0.000
time_starttransfer: 5.214
----------
time_total: 5.214-w 指定格式化文件
-o 请求重定向到
-s 静默,不现实进度
文章版权声明:除非注明,否则均为奥多云原创文章,转载或复制请以超链接形式并注明出处。




还没有评论,来说两句吧...