[Pyrex] Re: any ideas to speed this up?
Toby
tobia.conforto at linux.it
Thu Feb 23 10:23:26 CET 2006
Brian Blais wrote:
> t1=time.time()
> ...
> print time.time()-t1
You might want to use time.clock() for benchmarking algorithms.
time.time() measures the current (wall clock) time, so the difference
you print includes any time spent by the CPU on other processes, or
waiting for I/O, or responding to other computers on the network.
Instead time.clock() only measures the time spent by the CPU executing
your user code, discarding anything else. There's a catch: on most
platforms time.clock() has a worse resolution (on my Linux pc it's .01s)
So if you need to time algorithms that take much less than a second, you
will have to repeat them a number of times, like this:
t = time.clock()
for i in range(1000):
# stuff <<1s to measure goes here
print (time.clock() - t) / 1000
Toby
--
Signed/encrypted mail welcome. GPG/PGP Key-Id: 0x15C5C2EA
More information about the Pyrex
mailing list