Created
March 1, 2012 11:02
-
-
Save simonwheatley/1949105 to your computer and use it in GitHub Desktop.
Uses Curl to get the response time for a webpage, also regexes out the page gen time (this last relies on WP Super Cache's "Dynamic page generated in X.XX seconds." HTML comment)
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment