Ticket #3957 (partial) - ganeti_webmgr uses ganeti python namespace:
[ganeti_webmgr.git] / ganeti_web / cache / __init__.py
blob0aeb0a6de93589335ab69908ca66211d24a06d38
1 from datetime import datetime
3 class Timer():
5 def __init__(self, start=True):
6 self.start()
7 self.ticks = []
9 def start(self):
10 self.start = datetime.now()
11 self.ticks = []
12 self.last_tick = self.start
14 def stop(self):
15 self.end = datetime.now()
16 print ' Total time: %s' % (self.end - self.start)
18 def tick(self, msg=''):
19 now = datetime.now()
20 duration = now-self.last_tick
21 print ' %s : %s' % (msg, duration)
22 self.last_tick = now
23 self.ticks.append(duration.seconds + duration.microseconds/1000000.0)
26 class Counter(object):
27 """ simpler counter class """
29 def __init__(self):
30 self.value = 0
32 def __iadd__(self, other):
33 self.value += other
35 def __repr__(self):
36 return str(self.value)