diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-02-17 07:30:52 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-02-17 07:30:52 +0000 |
commit | 8321c6448d3121d5ba3d0ced237362a4a53fe15f (patch) | |
tree | 102f30d5702710c2896af5dc1ea1d279cab94c88 /speed-test | |
parent | 9440f0709a20a41437ce4a0144b5df90ca7133f2 (diff) | |
download | larch-8321c6448d3121d5ba3d0ced237362a4a53fe15f.tar.gz |
Improve memory use logging.
Diffstat (limited to 'speed-test')
-rwxr-xr-x | speed-test | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -28,6 +28,7 @@ import cliapp import cProfile +import gc import logging import os import random @@ -150,16 +151,23 @@ class SpeedTest(cliapp.Application): shutil.rmtree(location) def measure(self, items, func, finalize, profname): + + def log_memory_use(stage): + if self['log-memory-use']: + logging.info('%s memory use: %s' % (profname, stage)) + logging.info(' VmRSS: %s KiB' % self.vmrss()) + logging.info(' # objects: %d' % len(gc.get_objects())) + logging.info(' # garbage: %d' % len(gc.garbage)) + def helper(): + log_memory_use('at start') for item in items: func(item) - if self['log-memory-use']: - logging.debug('VmRSS %s pre-finalize: %s KiB' % - (profname, self.vmrss())) + log_memory_use('after calls') finalize() + log_memory_use('after finalize') print 'measuring', profname - logging.debug('VmRSS %s at start: %s KiB' % (profname, self.vmrss())) start_time = time.time() start = time.clock() if self['profile']: @@ -171,7 +179,6 @@ class SpeedTest(cliapp.Application): helper() end = time.clock() end_time = time.time() - logging.debug('VmRSS %s at end: %s KiB' % (profname, self.vmrss())) return end - start, end_time - start_time def vmrss(self): |