[pypy-svn] r58923 - in pypy/dist/pypy/rlib: . test

xoraxax at codespeak.net xoraxax at codespeak.net
Fri Oct 10 18:33:19 CEST 2008


Author: xoraxax
Date: Fri Oct 10 18:33:19 2008
New Revision: 58923

Modified:
   pypy/dist/pypy/rlib/test/test_timer.py
   pypy/dist/pypy/rlib/timer.py
Log:
Do not freeze timer values.

Modified: pypy/dist/pypy/rlib/test/test_timer.py
==============================================================================
--- pypy/dist/pypy/rlib/test/test_timer.py	(original)
+++ pypy/dist/pypy/rlib/test/test_timer.py	Fri Oct 10 18:33:19 2008
@@ -2,8 +2,13 @@
 from pypy.translator.c.test.test_genc import compile
 from pypy.annotation.policy import AnnotatorPolicy
 
+
+t = Timer()
+t.start("testc")
+t.stop("testc")
+
 def timer_user():
-    t = Timer()
+    assert "testc" not in t.timingorder
     t.start("testa")
     t.stop("testa")
     t.start("testb")
@@ -12,9 +17,10 @@
     t.stop("testb")
     t.dump()
 
+
 def test_compile_timer():
     policy = AnnotatorPolicy()
     policy.allow_someobjects = False
     f_compiled = compile(timer_user, [], annotatorpolicy=policy)
-    f_compiled(expected_extra_mallocs=0)
+    f_compiled(expected_extra_mallocs=2)
 

Modified: pypy/dist/pypy/rlib/timer.py
==============================================================================
--- pypy/dist/pypy/rlib/timer.py	(original)
+++ pypy/dist/pypy/rlib/timer.py	Fri Oct 10 18:33:19 2008
@@ -11,10 +11,16 @@
 
 class Timer:
     def __init__(self):
+        self.reset()
+
+    def reset(self):
         self.timings = {}
         self.levels = {}
         self.timingorder = []
 
+    def _freeze_(self):
+        self.reset()
+
     def start(self, timer):
         level = self.levels.setdefault(timer, -1)
         new_level = level + 1



More information about the Pypy-commit mailing list