Skip to content

Instantly share code, notes, and snippets.

@urbanslug
Last active April 12, 2017 10:37
Show Gist options
  • Save urbanslug/4b1d8756f284ec925df7e5b833e146b4 to your computer and use it in GitHub Desktop.
Save urbanslug/4b1d8756f284ec925df7e5b833e146b4 to your computer and use it in GitHub Desktop.

Get pretty request time breakdown from cURL with -w or --write-out:

$ curl -u username:password -w "@curl-format.txt" -o response.txt -H "Accept: text/html" -X GET "https://blog.urbanslug.com"

pass -s to get rid of the progress output:

$ curl -s -u username:password -w "@curl-format.txt" -o response.txt -H "Accept: text/html" -X GET "https://blog.urbanslug.com"

example curl-format.txt

Request time in seconds:\n
            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

Example result:

$ curl -s -u username:password -w "@curl-format.txt" -o response.txt -H "Accept: text/html" -X GET "https://blog.urbanslug.com"
Request time in seconds:
            time_namelookup:  0.005
               time_connect:  0.173
            time_appconnect:  0.536
           time_pretransfer:  0.536
              time_redirect:  0.000
         time_starttransfer:  0.705
                            ----------
                 time_total:  0.705

Attribution:
https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl
https://blog.josephscott.org/2011/10/14/timing-details-with-curl/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment