Skip to content

Instantly share code, notes, and snippets.

@voxxit
Created July 19, 2018 22:55
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 voxxit/2710ead33ee3b4e19b2ae1d510c36627 to your computer and use it in GitHub Desktop.
Save voxxit/2710ead33ee3b4e19b2ae1d510c36627 to your computer and use it in GitHub Desktop.
Wrapper script for curl to publish timings as JSON
#!/bin/bash
#
# curl wrapper returning timing information.
#
# curl format adapted from
# http://josephscott.org/archives/2011/10/timing-details-with-curl/
#
# Example usage:
# $ curlt http://www.apple.com
# $ time curlt http://www.apple.com -v
set -e
curl_format='{
"dns": %{time_namelookup},
"tcp": %{time_connect},
"tls": %{time_appconnect},
"pre_xfer": %{time_pretransfer},
"redirect": %{time_redirect},
"ttfb": %{time_starttransfer},
"total": %{time_total}
}\n'
exec curl -w "${curl_format}" -o/dev/null -s "${@}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment