Automating the YSLOW score and HAR using Firefox plugins(NetExport,YSlow)

I have used the following url as source for my experiment.

http://tech.groups.yahoo.com/group/exceptional-performance/message/822

Goal : To automate the following

1. To get YSLOW score of  a webpage

2. To get the Http Archive (HAR) of a webpage

Steps followed

1. Setup firefox with a new profile ‘PerformanceTest’.

  • Create a new profile(In Mac) : /Applications/Firefox.app/Contents/MacOS/firefox -P

2. Install the firebug, yslow and netexport plugins into this profile.

3. Create a web application URL to accept the YSLOW and HAR data

  • On mac(using default apache webserver) , create the Perl CGI scripts  under folder /Library/WebServer/CGI-Executables
  • get_yslow_data.pl Scrpt
  • #!/usr/bin/perl -wprint "Content-type: text/html\n\n";
    open FILE, '>/tmp/yslow.txt';
    #print "<pre>\n";if ($ENV{'REQUEST_METHOD'} eq "GET") {$request = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $request,$ENV{'CONTENT_LENGTH'})
    || die "Could not get query\n";
    
    }
    foreach $key (sort keys(%ENV)) {
    print FILE "$key = $ENV{$key}\n";
    }
    print FILE $request;
    close FILE;

     

  • get_har_data.pl script
  • #!/usr/bin/perl -wprint "Content-type: text/html\n\n";
    open FILE, '>/tmp/har.txt';
    #print "<pre>\n";if ($ENV{'REQUEST_METHOD'} eq "GET") {$request = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $request,$ENV{'CONTENT_LENGTH'})
    || die "Could not get query\n";
    
    }
    foreach $key (sort keys(%ENV)) {
    # print FILE "$key = $ENV{$key}\n";
    }
    print FILE $request;
    close FILE;

4. In firefox set the following plugin values

  • extensions.yslow.beaconUrl=http://127.0.0.1/cgi-bin/get_yslow_data.pl
  • extensions.yslow.autorun=true
  • extensions.firebug.netexport.beaconServerURL=http://127.0.0.1/cgi-bin/get_har_data.pl
  • extensions.firebug.netexport.autoExportToServer=true
  • extensions.firebug.netexport.alwaysEnableAutoExport=true
  • In the browser firebug panel, set the ‘AutoExport’ to on.
  • You can also set the send to URL using this panel , in the screenshot you could see that the data is sent to http://www.shwoslow.com

5. Run the firefox from the command line as following. This will generate the files ‘/tmp/yslow.txt’ and ‘/tmp/har.txt’ containing YSLOW and HAR data for that page.

6. Now you can keep this command in your shell/perl script for executing as automated. For example the following script

  • #!/bin/bashFIREFOX="/cygdrive/c/Program Files/Mozilla Firefox/"
    export PATH=$PATH:$FIREFOXURLS="http://www.yahoo.com http://www.google.com"
    for link in `echo $URLS`;
    do
    firefox.exe -P yslow -no-remote $link &
    PID=$!
    sleep 20
    kill $PID
    done

6. Thanks.

Want to tour Lakshadweep islands

After reading the following two blogs.. I want to tour lakshadweep islands

http://www.beontheroad.com/2010/03/cruise-to-lakshadweep-islands-faq-and.html

http://binux.blogspot.in/2005/07/lakshadweep-howto.html

Donno when I will visit the place.

Web Page Performance tools and reference urls

Timing the webpage html download through curl

The following is an example of curl usage for url ‘http://www.google.co.in&#8217; as a request made by Firefox-10

curl -w 'DNS Lookup Time:\t\t%{time_namelookup}\nConnect time:\t\t%{time_connect}\nPreXfer time:\t\t%{time_pretransfer}\nStartXfer time:\t\t%{time_starttransfer}\nTotal time:\t\t%{time_total}\nNumberofConnects:\t\t%{num_connects}\nNumberofRedirects:\t\t%{num_redirects}\nRedirectTime:\t\t%{time_redirect}\nHttpStatus:\t\t%{http_code}' --user-agent 'Mozilla/6.0 (Macintosh; I; Intel Mac OS X 11_7_9; de-LI; rv:1    .9b4) Gecko/2012010317 Firefox/10.0a4' -s http://www.google.co.in