(原文:https://josephscott.org/archives/2011/10/timing-details-with-curl/)
RT,这个需求是因为在服务器上如果curl某个地址的时候需要查看耗时。
新建一个文件:
vim curl
将下面的内容复制进去然后保存:
\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百度:
curl -w "@curl" -o /dev/null -s http://www.baidu.com
就能看到:

如果curl这个文件在其他位置,需要将path写在curl前面:
curl -w "@path/curl" -o /dev/null -s http://www.baidu.com