Last Updated: February 25, 2016
·
802
· adamstrawson

Investigate HTTP response times

I was investigating some odd behaviour on Smokeping and I wanted a quick way of finding HTTP response times for each step of the route.

I put together this bash script that does a Curl on a given Host/IP and returns the time to connect, the transfer start time, and the total response time.

#!/bin/bash
CURL="/usr/bin/curl"

echo -n "Enter Url to test: "
read url

URL="$url"
result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
IFS=':' read -a times <<< "${result}"

echo "Results: $URL"
echo "------------------------------------------------"
echo "| Connect Time | Transfer Start Time |  Total  |"
echo "------------------------------------------------"
echo "|   ${times[0]}ms    |       ${times[1]}ms       | ${times[2]}ms |"
echo "------------------------------------------------"

Please feel free to use, improvement suggestions are welcome.

2 Responses
Add your response

hey, use the bash script, no time output.

Enter Url to test: http://baidu.com

Results: http://baidu.com

| Connect Time | Transfer Start Time | Total |

| ms | ms | ms |

over 1 year ago ·

Hey David,

Sorry, there was a typo on one of the variables

Change:

IFS=':' read -a time <<< "${result}

To:

IFS=':' read -a times <<< "${result}

Cheers,
Adam

over 1 year ago ·