From 81860dc0a472e089a5d8b05efb1628f3f62fd513 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 10 May 2008 22:15:47 +0000 Subject: [PATCH] another approach --- test/orm/memusage.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/orm/memusage.py b/test/orm/memusage.py index 787b28d836..2ce94c1f59 100644 --- a/test/orm/memusage.py +++ b/test/orm/memusage.py @@ -27,19 +27,20 @@ def profile_memory(func): assert len(_sessions) == 0 - # 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)): - # adjusting down - if samples[i] < samples[i-1]: + for x in samples[-4:]: + if x != samples[-5]: + flatline = False 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]) + flatline = True + + if not flatline and samples[-1] > samples[0]: # object count is bigger than when it started + for x in samples[1:-2]: + if x > samples[-1]: # see if a spike bigger than the endpoint exists + break + else: + assert False, repr(samples) + " " + repr(flatline) + return profile def assert_no_mappers(): -- 2.47.3