From a89c772cd64c6790906734f7128947e0f453c7e3 Mon Sep 17 00:00:00 2001 From: rcoh Date: Wed, 15 Dec 2010 00:18:24 -0500 Subject: About halfway done with the Util cleanup. Some stuff left to do with scoping etc. --- util/TimeOps.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 util/TimeOps.py (limited to 'util/TimeOps.py') 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 -- cgit v1.2.3