[pypy-svn] r67428 - pypy/trunk/pypy/jit/tl
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Sep 2 14:03:11 CEST 2009
Author: cfbolz
Date: Wed Sep 2 14:03:10 2009
New Revision: 67428
Modified:
pypy/trunk/pypy/jit/tl/pypyjit_demo.py
Log:
An example loop that shows behaviour that I think is one of the next problems in
richards (apart from recompilation).
Modified: pypy/trunk/pypy/jit/tl/pypyjit_demo.py
==============================================================================
--- pypy/trunk/pypy/jit/tl/pypyjit_demo.py (original)
+++ pypy/trunk/pypy/jit/tl/pypyjit_demo.py Wed Sep 2 14:03:10 2009
@@ -5,16 +5,50 @@
__import__('test.' + TESTNAME)
print "---ending 1---"
+class A(object):
+ def __init__(self, x):
+ self.x = x
+ self.y = x
+ self.count = 0
+
+ def increment(self):
+ self.count += 1
+ count = self.count
+ self.reset(self.count)
+ self.count += count
+
+ def reset(self, howmuch):
+ for i in range(howmuch):
+ self.count -= 1
+
+ def f(self):
+ self.increment()
+ return self.x + self.y + 1
+
def simple_loop():
print "simple loop"
import time
+ global a
+ a = A(10)
+ a = A(10)
+ a = A(10)
+ a = A(10)
+ a = A(10)
+ a = A(1)
+ print a
+ print a
i = 0
- N = 100
+ N = 1000
#N = 10000000
step = 3
start = time.clock()
+ odd = 0
while i < N:
- i = i + step
+ i = i + a.f()
+ if i % 2:
+ i += 2
+ odd += 1
+ print a.count, i, odd
end = time.clock()
print i
print end-start, 'seconds'
More information about the Pypy-commit
mailing list