I need to have a base class which I will use to inherit other classes which I would like to measure execution time of its functions.
So intead of having something like this:
class Worker():
def doSomething(self):
start = time.time()
... do something
elapsed = (time.time() - start)
print "doSomething() took ", elapsed, " time to finish"
#outputs: doSomething() took XX time to finish
I would like to have something like this:
class Worker(BaseClass):
def doSomething(self):
... do something
#outputs the same: doSomething() took XX time to finish
So the BaseClass needs to dealing with measuring time
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…