curl http请求响应时间

 

1、直接访问使用:

curl -o /dev/null -s -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} www.baidu.com

 

输出变量需要按照%{variable_name}的格式,如果需要输出%,double一下即可,即%%,同时,\n是换行,\r是回车,\t是TAB。 

-w 指定格式化文件

-o 请求重定向到,不带此参数则控制台输出返回结果

-s 静默,不显示进度

 

2、定义时间格式化文件访问

#vim  curl-time.txt 
\n
              http: %{http_code}\n
               dns: %{time_namelookup}s\n
          redirect: %{time_redirect}s\n
      time_connect: %{time_connect}s\n
   time_appconnect: %{time_appconnect}s\n
  time_pretransfer: %{time_pretransfer}s\n
time_starttransfer: %{time_starttransfer}s\n
     size_download: %{size_download}bytes\n
    speed_download: %{speed_download}B/s\n
                  ----------\n
        time_total: %{time_total}s\n
\n
curl -w "@curl-time.txt" https://www.sogou.com/websearch/api/getcity

 

 

 

curl的部分时间等变量注释:

time_total 总时间

time_namelookup DNS解析时间

time_connect 连接时间

time_appconnect 连接建立完成时间

time_pretransfer 从开始到准备传输的时间

time_redirect 重定向时间

time_starttransfer 开始传输时间

 

文章参考:

https://blog.csdn.net/hqzxsc2006/article/details/50547684

https://blog.csdn.net/weifangan/article/details/80741981

 

posted @ 2020-12-22 11:58  草木物语  阅读(1302)  评论(0编辑  收藏  举报