Measure website response time through curl
November 12, 2010 8 Comments
In this article I will show you how you can get the response time of any damn website.I am going to use curl for that purpose.As we know curl is extremly powerful to fetch lot many thing.I got this idea from one of IBM DW article and wrote a script to do just that for me.So here is the script I write:
1 #!/bin/bash
2 CURL="/usr/bin/curl"
3 GAWK="/usr/bin/gawk"
4 echo -n "Please pass the url you want to measure: "
5 read url
6 URL="$url"
7 result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
8 echo " Time_Connect Time_startTransfer Time_total "
9 echo $result | $GAWK -F: '{ print $1" "$2" "$3}'
This is very ordinary script but it does the job it was intended to do.Here is the interaction with script below:
bhaskar@bhaskar-laptop_09:02:55_Fri Nov 12:/lvm/Adm_scripts> sudo ./measure_website_response
Please pass the url you want to measure: http://justlinux.com
Time_Connect Time_startTransfer Time_total
1.122 3.455 9.205
Hope this will help.
Cheers!
Bhaskar
Pingback: Links 14/11/2010: Scientific Linux 6.0 Alpha, Fedora and Wayland | Techrights
Wonderful post, very informative. I ponder why the other specialists of this sector don’t notice this. You should continue your writing. I am sure, you have a huge readers’ base already!|What’s Happening i’m new to this, I stumbled upon this I have found It positively helpful and it has aided me out loads. I am hoping to contribute & aid other customers like its aided me. Great job.
Cool! I have just started shell scripting. I will definitely have to try this script out.
I really like it, thx. I made a little change to use it in a loop and formatted the output.
#!/bin/bash
CURL=”/usr/bin/curl”
GAWK=”/usr/bin/gawk”
URL=”$1″
result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
echo “Host: $URL”
echo “Time_Connect Time_startTransfer Time_total
$(echo $result | $GAWK -F: ‘{ print $1” “$2” “$3}’)
” | column -t
:~# ./response_time.sh google.com
Host: google.com
Time_Connect Time_startTransfer Time_total
0.088 0.138 0.138
Pingback: A quick and dirty way of testing the performance of a service at Mark Needham
What are you measuring actually ? Can you analyze the time ? Definitely it is not the total time the page takes to download on our machine.
Use time, instead of using so large code.
#time curl -I “url”
Why not: curl -o /dev/null -s -w %{time_total}\\n http://www.google.com ?