aboutsummaryrefslogtreecommitdiff
path: root/util/TimeOps.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2010-12-15 00:18:24 -0500
committerGravatar rcoh <rcoh@mit.edu>2010-12-15 00:18:24 -0500
commita89c772cd64c6790906734f7128947e0f453c7e3 (patch)
tree250e0b0d235e1215fa7b40fcfd24b74028ccf643 /util/TimeOps.py
parent8cecf83f16fcdec5b3ee68cc40c2b360e0f845d0 (diff)
About halfway done with the Util cleanup. Some stuff left to do with scoping etc.
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