Calculating average time

Skip Montanaro skip at
Thu Jul 7 22:46:13 CEST 2005

    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()
        cumulative += time.time() - t
        n += 1

    print "average page load time:", cumulative/n, "seconds"


More information about the Python-list mailing list