curl 获取执行时相应时间

Tag: Linux Shell curl 
Posted on 2020-07-22

直接来命令

curl -o /dev/null -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" url

执行结果如下

# curl -o /dev/null -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" http://127.0.0.1/webmail/login/login.do
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22157    0 22157    0     0   597k      0 --:--:-- --:--:-- --:--:--  618k
0.000::0.000::0.031::0.036::611919.000

也可以加上 -s 参数去掉所有状态

# curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" http://172.16.0.8/webmail/login/login.do
0.002::0.002::0.048::0.056::395738.000


参数说明

-w:按照后面的格式写出rt

time_namelookup:DNS 解析域名[www.taobao.com]的时间 

time_commect:client和server端建立TCP 连接的时间

time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间

time_total:client发出请求;到web的server发送会所有的相应数据的时间

speed_download:下周速度  单位 byte/s


1. 建立TCP连接到server返回client第一个字节的时间:time_starttransfer - time_commect

2. server把响应数据发送给client的时间:time_total - time_starttransfer

 评论
张三
orz
李四
orz orz
李小四
orz orz orz
张小三
orz orz orz orz
  搜索
  Tags
全部   Ubuntu   Linux   Python   Windows   Shell   转发   浏览器   js   KMS   循环   MySQL   字体   html   css   DNS   电源   多线程   反向代理   重定向   原创   WinSCP   随机   随机数   VSCode   venv   vbs   多进程   远程调试   字典   生活   激活   线程池   日志   数据库   网卡   截取字符   进度条   安装   进程池   领带   uuid   tc   IP   iostat   import   GitHub   dpkg   DHCP   curl   crx   CPU   cloud-init   Chrome   BBR   Apt   iptables   Kitsunebi   subprocess   SSH   SoftEther   Set   samba   pyflakes   pip   Office   Nginx   NextCloud   List   libreoffice   kvm   Adobe  
  功能
You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!