Skip to content

Instantly share code, notes, and snippets.

@localhost
Created October 2, 2020 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localhost/1152187bfa0b2b0b313322d0b463d4bd to your computer and use it in GitHub Desktop.
Save localhost/1152187bfa0b2b0b313322d0b463d4bd to your computer and use it in GitHub Desktop.
cURL: Show request timing details

Inspired by Joseph Scott's post¹ and Radovan Svedic's comment² let's have a nice box formatting for cURL's timing output.

Usage:

curl -sw "@$HOME/.curl_time.txt" https://ddg.gg/
    
# or without website output
curl -o /dev/null -sw "@$HOME/.curl_time.txt" https://ddg.gg/

Don't forget to save .curl_time.txt from below to your home dir!

Example:

q@bullshit:~$ curl -o /dev/null -Lsw "@$HOME/.curl_time.txt" https://ddg.gg/

┌───▫ REQUEST TIMING ▫───┐
│namelookup...: 0,008404s│
│connect......: 0,134121s│
│appconnect...: 0,304982s│
│pretransfer..: 0,305334s│
│redirect.....: 0,341413s│
│starttransfer: 0,437185s│
│time_total...: 0,438552s│
│┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄│
│ server processing time │
│ (0,437185 - 0,305334)s │
└────────────────────────┘
q@bullshit:~$ echo 0,437185 - 0,305334|tr , .|bc
.131851
\n
┌───▫ REQUEST TIMING ▫───┐\n
│namelookup...: %{time_namelookup}s│\n
│connect......: %{time_connect}s│\n
│appconnect...: %{time_appconnect}s│\n
│pretransfer..: %{time_pretransfer}s│\n
│redirect.....: %{time_redirect}s│\n
│starttransfer: %{time_starttransfer}s│\n
│time_total...: %{time_total}s│\n
│┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄│\n
│ server processing time │\n
│ (%{time_starttransfer} - %{time_pretransfer})s │\n
└────────────────────────┘\n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment