
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 1.17 KB | hits: 13 | expires: Never
#!/bin/bash
# My script below is based on this one:
# http://unixbhaskar.wordpress.com/2010/11/12/measure-website-response-time-through-curl/
if [ -z $1 ]
then
echo "Please pass a URL to measure the response time for, e.g."
echo "sh infinite_response_time.sh http://google.com/ cookie1=123\;cookie2=abc"
exit
fi
URL=$1
COOKIE=$2
echo "Did you remember to backslash escape in the cookies param (if you used it)?"
echo ""
echo "Time: to connect / start transfer / total time / page generation"
# An infinite while loop…
while [ 1 ]
do
# Get the transfer and connection times
result=`curl --cookie "$COOKIE" -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
STAT1=`echo $result | gawk -F: '{ print $1" / "$2" / "$3}'`
# Get the page gen time.
# Comment out this line if you don't want the Super Cache page gen time
result=`curl --cookie "$COOKIE" -s $URL`
# Dynamic page generated in 1.103 seconds.
STAT2=`echo $result | sed "s/.*Dynamic page generated in \(.*\) seconds.*/\1/g"`
# If you don't have the page gen time, you'll need the next rather
# than the subsequent line.
# echo "$STAT1"
echo "$STAT1 / $STAT2"
# Gently does it
sleep 5s
done