Skip to content

Instantly share code, notes, and snippets.

@elblivion
Last active May 19, 2017 09:29
Show Gist options
  • Save elblivion/f13bb1349503d150664052e9d5c61aef to your computer and use it in GitHub Desktop.
Save elblivion/f13bb1349503d150664052e9d5c61aef to your computer and use it in GitHub Desktop.
curl-based endpoint test

curl-based endpoint testing

Statistics on DNS resolution, connection and SSL negotiation time for HTTP(S) endpoints.

Requires:

  • curl
  • bash

How to use:

  1. Download the test-endpoint.sh script
  2. Run it giving it a number of iterations and a URL

e.g.

$ bash test-endpoint.sh 4 images.contentful.com/cfexampleapi/1x0xpXu4pSGS4OukSyWGUK/cc1239c6385428ef26f4180190532818/doge.jpg
{ "dns": "0.524", "conn": "0.552", "ssl": "0.000", "total": "0.946" }
{ "dns": "0.005", "conn": "0.033", "ssl": "0.000", "total": "0.425" }
{ "dns": "0.005", "conn": "0.035", "ssl": "0.000", "total": "0.426" }
{ "dns": "0.004", "conn": "0.034", "ssl": "0.000", "total": "0.447" }

Output can optionally be pretty-printed with the jq tool (https://stedolan.github.io/jq/)

$ bash test-endpoint.sh 4 images.contentful.com/cfexampleapi/1x0xpXu4pSGS4OukSyWGUK/cc1239c6385428ef26f4180190532818/doge.jpg | jq .
{
  "dns": "0.005",
  "conn": "0.034",
  "ssl": "0.000",
  "total": "0.441"
}
{
  "dns": "0.005",
  "conn": "0.033",
  "ssl": "0.000",
  "total": "0.427"
}
{
  "dns": "0.004",
  "conn": "0.036",
  "ssl": "0.000",
  "total": "0.430"
}
{
  "dns": "0.004",
  "conn": "0.034",
  "ssl": "0.000",
  "total": "0.430"
}
#!/usr/bin/env bash
for i in $(seq 1 $1); do
curl -sSo /dev/null -w '{ "dns": "%{time_namelookup}", "conn": "%{time_connect}", "ssl": "%{time_appconnect}", "total": "%{time_total}" }\n' $2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment