Last active
December 13, 2019 12:09
-
-
Save robbwagoner/4cb594ead8a24b0c184109555c054b3e to your computer and use it in GitHub Desktop.
Measure Latency With Curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# curl wrapper returning timing information. | |
# | |
# ORIGIN: https://github.com/mat/dotfiles/blob/master/bin/curlt | |
# | |
# 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='{ | |
"time_namelookup": %{time_namelookup}, | |
"time_connect": %{time_connect}, | |
"time_appconnect": %{time_appconnect}, | |
"time_pretransfer": %{time_pretransfer}, | |
"time_redirect": %{time_redirect}, | |
"time_starttransfer": %{time_starttransfer}, | |
"time_total": %{time_total} | |
}' | |
exec curl -w "$curl_format" -D >(cat) -o /dev/null -s "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment