Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 1.17 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # My script below is based on this one:
  4. # http://unixbhaskar.wordpress.com/2010/11/12/measure-website-response-time-through-curl/
  5.  
  6. if [ -z $1 ]
  7. then
  8.         echo "Please pass a URL to measure the response time for, e.g."
  9.         echo "sh infinite_response_time.sh http://google.com/ cookie1=123\;cookie2=abc"
  10.         exit
  11. fi
  12.  
  13. URL=$1
  14. COOKIE=$2
  15.  
  16. echo "Did you remember to backslash escape in the cookies param (if you used it)?"
  17. echo ""
  18. echo "Time: to connect / start transfer / total time / page generation"
  19.  
  20. # An infinite while loop…
  21. while [ 1 ]
  22. do
  23.         # Get the transfer and connection times
  24.         result=`curl --cookie "$COOKIE" -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
  25.         STAT1=`echo $result | gawk -F: '{ print $1" / "$2" / "$3}'`
  26.  
  27.         # Get the page gen time.
  28.         # Comment out this line if you don't want the Super Cache page gen time
  29.         result=`curl --cookie "$COOKIE" -s $URL`
  30.         # Dynamic page generated in 1.103 seconds.
  31.         STAT2=`echo $result | sed "s/.*Dynamic page generated in \(.*\) seconds.*/\1/g"`
  32.  
  33.         # If you don't have the page gen time, you'll need the next rather
  34.         # than the subsequent line.
  35.         # echo "$STAT1"
  36.         echo "$STAT1 / $STAT2"
  37.  
  38.         # Gently does it
  39.         sleep 5s
  40. done