Created a timer class useful for debugging.
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Sep 2004 17:31:03 +0000 (17:31 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Sep 2004 17:31:03 +0000 (17:31 +0000)
src/lib/kofoto/timer.py [new file with mode: 0644]

diff --git a/src/lib/kofoto/timer.py b/src/lib/kofoto/timer.py
new file mode 100644 (file)
index 0000000..8b0dc15
--- /dev/null
@@ -0,0 +1,16 @@
+import time
+
+class Timer:
+    def __init__(self):
+        self.reset()
+
+    def reset(self):
+        self.time = time.time()
+
+    def get(self):
+        return time.time() - self.time
+
+    def getAndReset(self):
+        t = time.time() - self.time
+        self.reset()
+        return t