curl记录响应时间

新建curl-format.txt

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

使用

curl -i -w "@curl-format.txt" -o /dev/null -d "id=xxx&pwd=xxx" -X POST http://localhost:8080/api/login

命令行显示如下:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   329    0   293  100    36     65      8  0:00:04  0:00:04 --:--:--    65
    time_namelookup:  0.000
       time_connect:  0.018
    time_appconnect:  0.000
   time_pretransfer:  0.018
      time_redirect:  0.000
 time_starttransfer:  4.482
                    ----------
         time_total:  4.482

doc

相关推荐