• curl 度量时间


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

    1. Create a new file, curl-format.txt, and paste in:

           time_namelookup:  %{time_namelookup}s\n
              time_connect:  %{time_connect}s\n
           time_appconnect:  %{time_appconnect}s\n
          time_pretransfer:  %{time_pretransfer}s\n
             time_redirect:  %{time_redirect}s\n
        time_starttransfer:  %{time_starttransfer}s\n
                           ----------\n
                time_total:  %{time_total}s\n
      
    2. Make a request:

       curl -w "@curl-format.txt" -o /dev/null -s "http://wordpress.com/"
      

    Or on Windows, it's...

        curl -w "@curl-format.txt" -o NUL -s "http://wordpress.com/"


    What this does:

    -w "@curl-format.txt" tells cURL to use our format file
    -o /dev/null redirects the output of the request to /dev/null
    -s tells cURL not to show a progress meter
    "http://wordpress.com/" is the URL we are requesting. Use quotes particularly if your URL has "&" query string parameters

    And here is what you get back:

       time_namelookup:  0.001s
          time_connect:  0.037s
       time_appconnect:  0.000s
      time_pretransfer:  0.037s
         time_redirect:  0.000s
    time_starttransfer:  0.092s
                       ----------
            time_total:  0.164s
    
    
    

    Make a Linux/Mac shortcut (alias)

    alias curltime="curl -w \"@$HOME/.curl-format.txt\" -o /dev/null -s "
    

    Then you can simply call...

    curltime wordpress.org
    

    Thanks to commenter Pete Doyle!

    Make a Linux/Mac stand-alone script

    This script does not require a separate .txt file to contain the formatting.

    Create a new file, curltime, somewhere in your executable path, and paste in:

    #!/bin/bash
    
    curl -w @- -o /dev/null -s "$@" <<'EOF'
        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
    EOF
    

    Call the same way as the alias:

    curltime wordpress.org
    

     

    Make a Windows shortcut (aka BAT file)

    Put this command in CURLTIME.BAT (in the same folder as curl.exe)

    curl -w "@%~dp0curl-format.txt" -o NUL -s %*
    

    Then you can simply call...

    curltime wordpress.org
  • 相关阅读:
    JDBC之——一个单线程JDBC基类和一些注意事项
    java基础之——类的初始化顺序
    java线程之——synchronized的注意细节
    java线程之——sleep()与wait()的区别
    mysql view(视图)
    select的5中子句where,group by, havaing, order by, limit的使用顺序及实例
    Django的文件下载
    Django中图片的上传并显示
    Django中 基于form的注册,基于ajax的登录
    centos7 安装zabbix3.4
  • 原文地址:https://www.cnblogs.com/tekikesyo/p/15560265.html
Copyright © 2020-2023  润新知