使用cURL进行请求响应测试

  1. 新建一个curl-format文件
  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
  1. 执行请求

Linux/unix

curl -w "@curl-format" -o /dev/null -s "https://oschina.com/"

Windows

curl -w "@curl-format" -o /dev/null -s "https://oschina.com/"

命令参数解释 -w "@curl-formatt" cURL输出指定格式 -o /dev/null 重定向请求结果到 /dev/null -s cURL 不展示进度

响应结果

time_namelookup:  0.000000
       time_connect:  0.000000
    time_appconnect:  0.000000
   time_pretransfer:  0.000000
      time_redirect:  0.000000
 time_starttransfer:  0.000000
                    ----------
         time_total:  0.257694

参考地址:

https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl

转载于:https://my.oschina.net/websec/blog/1609647

你可能感兴趣的:(使用cURL进行请求响应测试)