# By Ed and Rudy Menendez import time class Timer(object): def __init__(self): self.bot = self.last_time = time.time() print u'Starting timer at %s' % self.last_time def tick(self, msg='Timer'): x = time.time() print '%s: Since inception %.3f, since last call %.3f' % (msg, x-self.bot, x - self.last_time) self.last_time = x