Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy?
for example:
start = time.clock()
... do
The short answer is: most of the time time.clock()
will be better.
However, if you're timing some hardware (for example some algorithm you put in the GPU), then time.clock()
will get rid of this time and time.time()
is the only solution left.
Note: whatever the method used, the timing will depend on factors you cannot control (when will the process switch, how often, ...), this is worse with time.time()
but exists also with time.clock()
, so you should never run one timing test only, but always run a series of test and look at mean/variance of the times.