Can i use firefox on a unix web server to measure page load speed ?

stilliard
stilliard used Ask the Experts™
on
Is it possible to install Firefox or another fully featured browser (as in not a text only browser) on a unix web server. And then run a site though it, and time how long it takes.
If possible, also measure how long each component takes.
I have found sites such as the following, who measure page load time, and i can mostly create this in php, but I'm using curl and other requests, while i think if i could install a browser on the server, and then run sites through it and time sections i could replicate this.
Similar to:
http://tools.pingdom.com/ 
http://mon.itor.us/
http://www.octagate.com/service/SiteTimer/

Anyone have experience with this, or any ideas, please let me know.
Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
There are FF plugins for this, such as this one which I have used:
https://addons.mozilla.org/en-US/firefox/addon/3371/ 

Author

Commented:
mattvmotas,
Sorry i must not have explained my issue very well, i want to install firefox on the server, therefore taking control of it from the command line. Then i will be running my own scripts on sites to monitor this, similar to the sites listed.
I am not looking for a way to do this with plugins or other sites as that would be manual, this needs to be at a server level in order for me to track these things via crons and other server based event schedules.

Commented:
You can somehow run Firefox on a server (you need a GUI mode on it).
Then you can do "firefox <URL>" and new tab will be open in the existing process.
The problem is that you have no response back on full site opening.
What you can do is to set your HTTP proxy, and make the Firefox work with it. Then you can analyze the proxy log for checking when each URLs were taken.
The only problem exists: how to work with Javascript "sleep(1000);"-like programs that then display some info... I don't know.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Commented:
There is an excellent framework for web testing called Watir. Essentially its a ruby based project which allows you to take control of a web browser... javascript engine and all... (yes you can control it from command prompt almost entirely, some pop-ups etc can be quite annoying though...)

Watir works for firefox and IE although I've only tested this on linux+firefox

This sample ruby script will open a new firefox window and browse to the URL you feed it..

IE: ./test.rb

#!/usr/bin/ruby
require "rubygems"
require "firewatir"  #loads firefox watir extensions
include FireWatir   #I'm not sure why but this is needed otherwise the ffx.close doesnt work
ffx=Firefox.new   #opens a new window
ffx.goto("http://google.com")   #punches in the URL and hits go.  <- you want to time this
ffx.close       #closes off the window  .. Note this only executes once the .goto() above has fully loaded the page

#NB use "irb" and type this in manually if you like ^^

Personally I'm not a ruby coder but I'm more than 100% sure it wont take you too long to find out how to simply "time" the "ffx.goto" bit... once you have that sorted out you can make a ruby server which accepts URLS and spits out the REAL firefox/IE load speed.   You might also want a firefox plugin that avoids cache on the testing website.

For a quick fix if you done know ruby just run this as a script with the "time" command :
$ time "test.rb"

This does not calculate 100% accurately as it doesn't include the time it takes firefox load, open the new window or how long it takes ruby to load firewatir/rubygems....

To do this well a bit of ruby experience and reading Watir documentation would be best, I would guess that it can be done through a persistent ruby script that holding an existing window under its control, accepts new URLs, browses to them and spits out how long it took.  I would help if I could but I'm sure a million ruby programmers would be insulted by my fumblings. I'm working on something later this week however.

Note: I have not covered how to install Watir.... You also need to install a firefox plugin called the JSSH plugin..  More @ http://wiki.openqa.org/display/WTR/FireWatir+Installation

Also just a note but as you are running this on a server (presumably under a VNC server or similar) remember that most home users like myself will probably have slower DNS queries and less bandwidth.
Commented:
Just another note, I figured out how to test the load speed hopefully.

Ruby already  includes a benchmarking class: http://ruby-doc.org/core/classes/Benchmark.html
Heres my script:

This script also tests a browser refresh so you can take it from there.

#!/usr/bin/ruby
#
#
require "rubygems"
require "benchmark"
require "firewatir"
include FireWatir
ff=Firefox.new
puts "Testing load time on textfiles.com"
puts Benchmark.measure {ff.goto("http://textfiles.com")}
puts "testing refresh time"
puts Benchmark.measure {ff.refresh}
puts "Lets time google.com"
puts Benchmark.measure {ff.goto("http://google.com")}
puts "and lets see if google loads faster 2nd time"
puts Benchmark.measure {ff.goto("http://google.com")}
ff.close


and this is the output i got:
$ ./timer.rb
Testing load time on textfiles.com
  0.000000   0.000000   0.000000 (  0.723822)
testing refresh time
  0.010000   0.000000   0.010000 (  7.643350)
Lets time google.com
  0.000000   0.010000   0.010000 (  2.553141)
and lets see if google loads faster 2nd time
  0.030000   0.000000   0.030000 ( 31.678997)



^^ for the record..... yes... that last result was 31 seconds, wifi...

Author

Commented:
@distark
sorry my reply is so late!

Your suggestion works great, im only testing it so far on my local computer but works for this really well cheers.

Are there any ways using Watir / FireWatir, to list out page components it loads (css, images etc?), no-problem if it doesn't, just icing on the cake really.

Author

Commented:
Cheers,

again though, if you have any ideas for the css  javascript load times being separated out so we could see which components  objects of the page are at what speed, that would be really brilliant!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial