[pypy-svn] r47451 - in pypy/dist/pypy/rpython/memory: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Oct 14 19:26:30 CEST 2007
Author: arigo
Date: Sun Oct 14 19:26:29 2007
New Revision: 47451
Modified:
pypy/dist/pypy/rpython/memory/gcwrapper.py
pypy/dist/pypy/rpython/memory/test/test_gc.py
Log:
A test that asks for the id() of a relatively large number of objects.
The goal is to make this test run faster than it does now on a SemiSpaceGC.
Modified: pypy/dist/pypy/rpython/memory/gcwrapper.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gcwrapper.py (original)
+++ pypy/dist/pypy/rpython/memory/gcwrapper.py Sun Oct 14 19:26:29 2007
@@ -50,6 +50,10 @@
else:
return lltype.malloc(TYPE, n, flavor=flavor, zero=zero)
+ def free(self, TYPE, flavor='gc'):
+ assert flavor != 'gc'
+ return lltype.free(TYPE, flavor=flavor)
+
def setfield(self, obj, fieldname, fieldvalue):
STRUCT = lltype.typeOf(obj).TO
addr = llmemory.cast_ptr_to_adr(obj)
Modified: pypy/dist/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_gc.py Sun Oct 14 19:26:29 2007
@@ -270,6 +270,26 @@
res = self.interpret(f, [])
assert res == 0
+ def test_many_ids(self):
+ class A(object):
+ pass
+ def f():
+ from pypy.rpython.lltypesystem import lltype, rffi
+ alist = [A() for i in range(500)]
+ idarray = lltype.malloc(rffi.INTP.TO, len(alist), flavor='raw')
+ # Compute the id of all elements of the list. The goal is
+ # to not allocate memory, so that if the GC needs memory to
+ # remember the ids, it will trigger some collections itself
+ for i in range(len(alist)):
+ idarray[i] = id(alist[i])
+ for j in range(2):
+ if j == 1: # allocate some stuff between the two iterations
+ [A() for i in range(200)]
+ for i in range(len(alist)):
+ assert idarray[i] == id(alist[i])
+ lltype.free(idarray, flavor='raw')
+ self.interpret(f, [])
+
class TestMarkSweepGC(GCTest):
from pypy.rpython.memory.gc.marksweep import MarkSweepGC as GCClass
More information about the Pypy-commit
mailing list