aboutsummaryrefslogtreecommitdiff
path: root/util/TimeOps.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/TimeOps.py')
-rw-r--r--util/TimeOps.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/util/TimeOps.py b/util/TimeOps.py
new file mode 100644
index 0000000..dcd5038
--- /dev/null
+++ b/util/TimeOps.py
@@ -0,0 +1,19 @@
+import time as clock
+def time():
+ return clock.time()*1000 #all times in MS
+class Stopwatch:
+ def __init__(self):
+ self.running = False
+ self.startTime = -1
+ self.stopTime = -1
+ def start(self):
+ self.startTime = time()
+ self.running = True
+ def elapsed(self):
+ if self.running:
+ return time()-self.startTime
+ else:
+ return self.stopTime - self.startTime
+ def stop(self):
+ self.stopTime = time()
+ self.running = False