Re: Calculating average time
have a look at the "timeit" module aswell GregM wrote: > Hi, > I'm hoping that someone can point me in the right direction with this. > What I would like to do is calculate the average time it takes to load > a page. I've been searching the net and reading lots but I haven't > found anything that helps too much. I'm testing our web site and hiting > +6000 urls per test. Here is a subset of what I'm doing. > > import IEC > #IE controller from http://www.mayukhbose.com/python/IEC/index.php > from win32com.client import Dispatch > import time > import datetime > from sys import exc_info, stdout, argv, exit > failedlinks = [] > links = open(testfile).readlines() > totalNumberTests = len(links) > ie = IEC.IEController() > start = datetime.datetime.today() > # asctime() returns a human readable time stamp whereas time() doesn't > startTimeStr = time.asctime() > for link in links: > start = datetime.datetime.today() > ie.Navigate(link) > end = datetime.datetime.today() > pagetext = ie.GetDocumentText() > #check the returned web page for some things > if not (re.search(searchterm, pagetext): >failedlinks.append(link) > ie.CloseWindow() > finised = datetime.datetime.today() > finishedTimeStr = time.asctime() > # then I print out results, times and etc. > > So: > 1. Is there a better time function to use? > > 2. To calculate the average times do I need to split up min, sec, and > msec and then just do a standard average calculation or is there a > better way? > > 3. is there a more efficient way to do this? > > 4. kind of OT but is there any control like this for Mozilla or > firefox? > > This is not intended to be any sort of load tester just a url > validation and page check. > > Thanks in advance. > Greg. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Calculating average time
Thanks Skip. As usual I want to make it harder then it actually is. -- http://mail.python.org/mailman/listinfo/python-list
Re: Calculating average time
greg> 1. Is there a better time function to use? For this particular scenario I think time.time() is probably what you want: cumulative = 0.0 n = 0 for link in links: t = time.time() ie.Navigate(link) cumulative += time.time() - t n += 1 print "average page load time:", cumulative/n, "seconds" Skip -- http://mail.python.org/mailman/listinfo/python-list
Calculating average time
Hi, I'm hoping that someone can point me in the right direction with this. What I would like to do is calculate the average time it takes to load a page. I've been searching the net and reading lots but I haven't found anything that helps too much. I'm testing our web site and hiting +6000 urls per test. Here is a subset of what I'm doing. import IEC #IE controller from http://www.mayukhbose.com/python/IEC/index.php from win32com.client import Dispatch import time import datetime from sys import exc_info, stdout, argv, exit failedlinks = [] links = open(testfile).readlines() totalNumberTests = len(links) ie = IEC.IEController() start = datetime.datetime.today() # asctime() returns a human readable time stamp whereas time() doesn't startTimeStr = time.asctime() for link in links: start = datetime.datetime.today() ie.Navigate(link) end = datetime.datetime.today() pagetext = ie.GetDocumentText() #check the returned web page for some things if not (re.search(searchterm, pagetext): failedlinks.append(link) ie.CloseWindow() finised = datetime.datetime.today() finishedTimeStr = time.asctime() # then I print out results, times and etc. So: 1. Is there a better time function to use? 2. To calculate the average times do I need to split up min, sec, and msec and then just do a standard average calculation or is there a better way? 3. is there a more efficient way to do this? 4. kind of OT but is there any control like this for Mozilla or firefox? This is not intended to be any sort of load tester just a url validation and page check. Thanks in advance. Greg. -- http://mail.python.org/mailman/listinfo/python-list