[pypy-svn] r71743 - in pypy/trunk/pypy/rlib: . test

fijal at codespeak.net fijal at codespeak.net
Thu Mar 4 23:00:41 CET 2010


Author: fijal
Date: Thu Mar  4 23:00:39 2010
New Revision: 71743

Modified:
   pypy/trunk/pypy/rlib/test/test_timer.py
   pypy/trunk/pypy/rlib/timer.py
Log:
A new interface, to avoid concatenation of strings in case we don't actually
use timer.


Modified: pypy/trunk/pypy/rlib/test/test_timer.py
==============================================================================
--- pypy/trunk/pypy/rlib/test/test_timer.py	(original)
+++ pypy/trunk/pypy/rlib/test/test_timer.py	Thu Mar  4 23:00:39 2010
@@ -15,6 +15,8 @@
     t.start("testb")
     t.stop("testb")
     t.stop("testb")
+    t.start_name("test", "one")
+    t.stop_name("test", "one")
     t.dump()
 
 

Modified: pypy/trunk/pypy/rlib/timer.py
==============================================================================
--- pypy/trunk/pypy/rlib/timer.py	(original)
+++ pypy/trunk/pypy/rlib/timer.py	Thu Mar  4 23:00:39 2010
@@ -30,6 +30,9 @@
         self.timings[name] = time.time() - self.timings.get(name, 0)
         self.levels[timer] = new_level
 
+    def start_name(self, timerone, timertwo):
+        self.start(timerone + " " + timertwo)
+
     def stop(self, timer):
         level = self.levels.setdefault(timer, -1)
         if level == -1:
@@ -39,6 +42,9 @@
             self.timings[name] = time.time() - self.timings[name]
             self.levels[timer] = level - 1
 
+    def stop_name(self, timerone, timertwo):
+        self.stop(timerone + " " + timertwo)
+
     def value(self, timer):
         level = self.levels.get(timer, -1)
         if level == -1:
@@ -58,8 +64,12 @@
 class DummyTimer:
     def start(self, timer):
         pass
+    def start_name(self, timerone, timertwo):
+        pass
     def stop(self, timer):
         pass
+    def stop_name(self, timerone, timertwo):
+        pass
     def value(self, timer):
         return "Timing disabled"
     def dump(self):



More information about the Pypy-commit mailing list