diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-05-10 19:27:05 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-05-10 19:27:05 +0000 |
commit | 92fbce57a31f883af1d1c55e4be5ff399d2d1e76 (patch) | |
tree | 44133b2a7fa916a40751c4cdcc2796f9e304b22b /test/orm/memusage.py | |
parent | 8413454b50cffcce567ee229f676d000b62785c0 (diff) | |
download | sqlalchemy-92fbce57a31f883af1d1c55e4be5ff399d2d1e76.tar.gz |
py2.4 seems to have different memory behavior than 2.5, test for both "adjusting down" as well as "flatline"
Diffstat (limited to 'test/orm/memusage.py')
-rw-r--r-- | test/orm/memusage.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/test/orm/memusage.py b/test/orm/memusage.py index f9c645c8b..845b19017 100644 --- a/test/orm/memusage.py +++ b/test/orm/memusage.py @@ -26,14 +26,20 @@ def profile_memory(func): print "sample gc sizes:", samples assert len(_sessions) == 0 - - # TODO: this test only finds pure "growing" tests. - # if a drop is detected, it's assumed that GC is able - # to reduce memory. better methodology would - # make this more accurate. + + # look in the last 20 entries. we look for one of two patterns: + # either "flatline", i.e. 103240, 103240, 103240, 103240, .... + # or "adjusting down", i.e. 103240, 103248, 103256, 103104, 103112, .... + for i in range(len(samples) - 20, len(samples)): - if samples[i] > samples[i-1]: - assert False, repr(samples) + " %d > %d" % (samples[i], samples[i-1]) + # adjusting down + if samples[i] < samples[i-1]: + break + else: + # no adjusting down. check for "flatline" + for i in range(len(samples) - 20, len(samples)): + if samples[i] > samples[i-1]: + assert False, repr(samples) + " %d > %d" % (samples[i], samples[i-1]) return profile def assert_no_mappers(): @@ -48,6 +54,7 @@ class EnsureZeroed(_base.ORMTest): class MemUsageTest(EnsureZeroed): + # ensure a pure growing test trips the assertion @testing.fails_if(lambda:True) def test_fixture(self): class Foo(object): |