diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-09-06 19:44:07 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-09-06 19:44:07 +0100 |
commit | 267b049865cc239e98847ea013dd9c88abe3f8e6 (patch) | |
tree | 73821661e3a8ec4ff99fba84f91a7f49f8acb561 | |
parent | 52a3446e7c69064e300ccc312d619cc206787c2c (diff) | |
download | larch-267b049865cc239e98847ea013dd9c88abe3f8e6.tar.gz |
Improve refcount-speed to not fail if it runs very fast
Patch from Lars Kruse
-rwxr-xr-x | refcount-speed | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/refcount-speed b/refcount-speed index 2edac1a..eb489ed 100755 --- a/refcount-speed +++ b/refcount-speed @@ -106,8 +106,18 @@ class RefcountSpeedTest(cliapp.Application): def helper(): n = self.settings['times'] log_memory_use('at start') - for i in xrange(n): - func() + finished = False + while not finished: + for i in xrange(n): + func() + if time.clock() > start: + # at least one time unit passed - this is enough + finished = True + else: + # Not a single time unit passed: we need more iterations. + # Multiply 'times' by 10 and execute the remaining 9 loops. + self.settings['times'] *= 10 + n *= 9 log_memory_use('after calls') print 'measuring', profname |