Changeset 7007


Ignore:
Timestamp:
May 11, 2009, 9:56:45 AM (11 years ago)
Author:
rwilson
Message:

Improved memory reporting under Linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/log.py

    r7006 r7007  
    192192    if sys.platform != 'win32':
    193193        _proc_status = '/proc/%d/status' % os.getpid()
    194         _scale = {'KB': 1024.0, 'MB': 1024.0*1024.0, 'GB': 1024.0*1024.0*1024.0,
    195                   'kB': 1024.0, 'mB': 1024.0*1024.0, 'gB': 1024.0*1024.0*1024.0}
     194        _scale = {'KB': 1024, 'MB': 1024*1024, 'GB': 1024*1024*1024,
     195                  'kB': 1024, 'mB': 1024*1024, 'gB': 1024*1024*1024}
    196196
    197197        def _VmB(VmKey):
     
    230230            return _VmB('VmStk:') - since
    231231
    232         msg = ('Resource usage: memory=%.1f resident=%.1f stacksize=%.1f'
    233                % (memory()/_scale['GB'], resident()/_scale['GB'],
    234                   stacksize()/_scale['GB']))
     232        msg = ('Resource usage: memory=%.1fMB resident=%.1fMB stacksize=%.1fMB'
     233               % (memory()/_scale['MB'], resident()/_scale['MB'],
     234                  stacksize()/_scale['MB']))
    235235        log(level, msg)
    236236    else:
     
    241241if __name__ == '__main__':
    242242##    critical('Testing exception capturing')
    243     resource_usage()
     243    def test_it(num=100):
     244        if num > 0:
     245            test_it(num-1)
     246        else:
     247            resource_usage()
     248
     249    import numpy as num
     250   
     251    a = num.zeros((1000,1000), num.float)
     252
     253    test_it()
Note: See TracChangeset for help on using the changeset viewer.