[Tutor] More problems with Learning Python example (fwd)
alan.gauld at freenet.co.uk
Fri Aug 12 10:58:59 CEST 2005
> Running lots_of_appends 100 times took 0.460 seconds.
> Running one_multiply 100 times took 0.000 seconds. <<----- ?
> Running lots_of_appends 100 times took 0.440 seconds.
> Running one_multiply 100 times took 0.010 seconds.
> Is the indicated result a fluke value which I can just
> disregard or is there a problem with my code? The 0.000
> value shows up about once in every 25-30 runs.
As you can see the multiply function is much faster and
the 0.000 figure just means the timing was so small it
didn't register - maybe your PC just happened not to be
doing anything else at the time so the code was still
in RAM or somesuch.... This is a good example of why timing
tests must be done over many repetitions and averaged.
Since you are running near the limit of recordability
you might increase the number of loop iterations to 1000...
More information about the Tutor