time.time or time.clock

dwblas at gmail.com dwblas at gmail.com
Mon Jan 14 18:50:14 CET 2008

time.clock() isn't high enough resolution for Ubuntu, and time.time()
high enough resolution on windows.

Take a look at datetime.  It is good to the micro-second on Linux and
milli-second on Windows.

import datetime
for j in range(100000):
   x = j+1     # wait a small amount of time
print "Elapsed time =", datetime.datetime.now()-begin_time

## You can also access the individual time values
print begin_time.second
print begin_time.microsecond     ## etc.

More information about the Python-list mailing list