[Tutor] Tutor] Re: newbie looking for code suggestions
Gregor Lingl
glingl@aon.at
Mon, 23 Sep 2002 10:01:52 +0200
Bob Roher schrieb:
>Is there a way to import time into the program, say
>before the loop starts and have it compare start and stop times
>to give some idea of cpu time? I would like to have some idea of
>time used when I try some of the ideas I've seen here.
>
>
>
You may use this function:
from time import clock
def gettime(repetitions, function, *arguments):
start = clock()
for i in range(repetitions):
function(*arguments)
end = clock()
return end - start
which measures the time used for repetitions repetitions
of the function function with an arbitrary number of arguments.
Regards
Gregor
>
>_______________________________________________
>Tutor maillist - Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>