POSTing with CURL with timings

June 7, 2019

I wanted to do a POST with CURL with a JSON payload and produce some performance stats in the process.

First create this file as curl-format.txt:

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
time_total:  %{time_total}\n

Next, run the following curl command:

$ curl --header "Content-Type: application/json" \
    --request POST \
    --data '{ "userName": "drumcoder", "password": "sekr1t", "forceSignIn": true, "ipAddress": "" }' \
    -o /dev/null \
    -w "@curl-format.txt" \

This produces output like:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100    37  100    88    180    429 --:--:-- --:--:-- --:--:--   609
 time_namelookup:  0.062041
       time_connect:  0.074656
    time_appconnect:  0.000000
   time_pretransfer:  0.074685
      time_redirect:  0.000000
 time_starttransfer:  0.205717
         time_total:  0.205750

The timings are in seconds, and the definitions are available at

These include:

  • time_starttransfer The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.

  • time_total The total time, in seconds, that the full operation lasted.