Skip to content

Instantly share code, notes, and snippets.

@ctran
Last active April 27, 2023 03:17
Show Gist options
  • Save ctran/3f0d681a1ae12622f4f397cbfeac3750 to your computer and use it in GitHub Desktop.
Save ctran/3f0d681a1ae12622f4f397cbfeac3750 to your computer and use it in GitHub Desktop.
Run curl with some timing

This can be run with

bash <(https://gist.githubusercontent.com/ctran/3f0d681a1ae12622f4f397cbfeac3750/raw/ea4a47fdb7f0e56009f4265c231fe22035effffe/curltime) url

or

curl -s https://gist.githubusercontent.com/ctran/3f0d681a1ae12622f4f397cbfeac3750/raw/ea4a47fdb7f0e56009f4265c231fe22035effffe/curltime) | bash -s url
#!/usr/bin/env bash
# See https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment