Skip to content

How to measure response time 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://example.com/"
  3. To output only average time, try this:
    curl -w "@curl-format.txt" -o /dev/null -s "http://example.com/" |grep time_total

    the output will be something like that:

     time_total: 0.085987s
  4.  To make multiple requests, just add another url’s:
    curl -w "@curl-format.txt" -o /dev/null -s "http://example.com/" "http://example.com/" "http://example.com/" "http://example.com/" |grep time_total
Published inBatchLinuxOtherScriptShell