[clug] A script to measure time to load a web page

Michael Still mikal at stillhq.com
Thu Mar 27 00:59:17 GMT 2008


Keith Goggin wrote:
> Hi,
> 
> I need to record the time it takes to load a web page at different times of 
> the day, for example hourly for 24 hours.

Are you interested in just the time to get the base HTML, or the time to
get that and all the elements needed to render the page completely? What
part of the system are you trying to measure?

If its just the base HTML, how about something like (in python):

------------------------------------------

#!/usr/bin/python

import datetime
import urllib

# I don't know off the top of my head if urlopen() returns before all
# the content has arrived from the remote server
start = datetime.datetime.now()
remote = urllib.urlopen('http://www.stillhq.com')
remote.readlines()
end = datetime.datetime.now()

delay = end - start
print ('Download took %d seconds, %d microseconds'
       %(delay.seconds, delay.microseconds))

-------------------------------------------

Cheers,
Mikal


More information about the linux mailing list