1 """ Tabakutilities. """
6 from .constants import DEBUG
9 def debug_timer(label, debug=False):
10 """ A decorator for printing how long a function took if debug is true.
14 def wrapper(*args, **kw):
15 start_time = time.time()
19 duration = time.time() - start_time
21 print "%s [%g seconds]" % (label, duration)
26 class DetailedTimer(object):
27 """ A detailed timer for overly complex functions.
29 def __init__(self, title, debug=False):
34 # fast funtions with the correct signature
41 print "---- %s ----" % self.title
42 self.times.append(time.time())
46 print " %s: %s" % (label, now - self.times[-1])
47 self.times.append(now)
53 print " %s: %s" % ("total", time.time() - self.times[0])