[pypy-commit] pypy default: Correctly reset the state between iterations. Before this change, successive iterations would take slightly longer and

arigo noreply at buildbot.pypy.org
Mon May 5 13:59:23 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r71277:c1d1f4dd5f5f
Date: 2014-05-05 13:58 +0200
http://bitbucket.org/pypy/pypy/changeset/c1d1f4dd5f5f/

Log:	Correctly reset the state between iterations. Before this change,
	successive iterations would take slightly longer and longer to
	execute, with no bound; roughly 2-4% slower every 500 iterations.

diff --git a/rpython/translator/goal/richards.py b/rpython/translator/goal/richards.py
--- a/rpython/translator/goal/richards.py
+++ b/rpython/translator/goal/richards.py
@@ -144,6 +144,9 @@
 
 class TaskWorkArea(object):
     def __init__(self):
+        self.reset()
+
+    def reset(self):
         self.taskTab = [None] * TASKTABSIZE
 
         self.taskList = None
@@ -151,7 +154,6 @@
         self.holdCount = 0
         self.qpktCount = 0
 
-taskWorkArea = TaskWorkArea()
 
 class Task(TaskState):
 
@@ -361,8 +363,7 @@
 
     def run(self, iterations):
         for i in xrange(iterations):
-            taskWorkArea.holdCount = 0
-            taskWorkArea.qpktCount = 0
+            taskWorkArea.reset()
 
             IdleTask(I_IDLE, 1, 10000, TaskState().running(), IdleTaskRec())
 


More information about the pypy-commit mailing list