blob: 502a359a60f329fe9c760255d4e251854c880b9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import time
class Timer:
def stop(self):
if self.startedAt > -1:
self.total = self.total + (time.time() - self.startedAt)
self.startedAt = -1
def start(self):
if self.startedAt == -1:
self.startedAt = time.time()
def elapsed(self):
if self.startedAt == -1:
return self.total
else:
return self.total + (time.time() - self.startedAt)
def __init__(self, start = 1):
self.total = 0
self.startedAt = -1
self.start()
|