How can I time a method of a class in python using Timeit

silverburgh.meryl at gmail.com silverburgh.meryl at gmail.com
Thu May 24 11:36:10 EDT 2007


Hi,

I am using timeit to time a global function like this

t = timeit.Timer("timeTest()","from __main__ import timeTest")
result = t.timeit();


But how can i use timeit to time a function in a class?
class FetchUrlThread(threading.Thread):
    def aFunction(self):
           # do something ....

    def run(self):
            # how can I time how long does aFunction() take here?
            aFunction();

Thank you.




More information about the Python-list mailing list