Package topo :: Package misc :: Module memuse
[hide private]
[frames] | no frames]

Module memuse

source code

Functions for measuring memory usage, to allow usage to be optimized.

Examples:

bin/python -c 'execfile("topo/misc/memuse.py") ; print topsize_mb()'

./topographica -c 'from topo.misc import memuse' -c 'print memuse.topsize_mb()'

./topographica -c 'from topo.misc import memuse, asizeof' -c 'print memuse.topsize_mb()'

./topographica -a -c 'from topo.misc import memuse, asizeof' -c 'print memuse.topsize_mb()'

./topographica -a -c 'from topo.misc import memuse, asizeof' examples/tiny.ty -c 'print memuse.allsizes_mb()'

./topographica -a -c 'from topo.misc import memuse, asizeof' -c 'memuse.memuse_batch("examples/tiny.ty",cortex_density=20)'

./topographica -a -c 'from topo.misc import memuse, asizeof' -c 'memuse.memuse_batch("examples/tiny.ty",times=[0,100],analysis_fn=memuse.plotting_and_saving_analysis_fn,cortex_density=20)'

$Id: memuse.py 11326 2010-07-30 15:42:45Z jbednar $


Version: $Revision: 10367 $

Functions [hide private]
 
cmd_to_string(cmd)
Run a system command as in os.system(), but capture the stdout and return it as a string.
source code
 
topsize()
Return the RES size of this process as reported by the top(1) command.
source code
 
simsize()
Return the size of topo.sim reported by asizeof.asizeof().
source code
 
mb(bytes)
Format the given value in bytes as a string in megabytes
source code
 
topsize_mb()
String-formatted version of the RES size of this process reported by top(1).
source code
 
simsize_mb()
String-formatted version of the value reported by asizeof(topo.sim).
source code
 
wtsize_mb()
String-formatted version of the memory taken by the weights, from print_sizes().
source code
 
allsizes_mb()
Collates results from topsize, simsize, and wtsize.
source code
 
default_memuse_analysis_fn(prefix='')
Basic memuse function for use with memuse_batch()
source code
 
plotting_and_saving_analysis_fn(prefix='')
For use with memuse_batch() to test snapshot and plotting memory usage.
source code
 
memuse_batch(script_file, times=[0], analysis_fn=<function default_memuse_analysis_fn at 0xbe965a4>, **params)
Similar to run_batch, but analyzes the memory requirement of a simulation at different times.
source code
Variables [hide private]
  __package__ = 'topo.misc'
Function Details [hide private]

simsize()

source code 

Return the size of topo.sim reported by asizeof.asizeof(). This estimate does not currently include any numpy arrays, and may also be missing other important items.

Python 2.6 supports getsizeof() and a __sizeof__ attribute that user code can implement, which should provide a more accurate estimate.

allsizes_mb()

source code 

Collates results from topsize, simsize, and wtsize.

Formatted to suggest that the topsize is made up of code (not currently estimated), topo.sim (apart from weights), and weights.

memuse_batch(script_file, times=[0], analysis_fn=<function default_memuse_analysis_fn at 0xbe965a4>, **params)

source code 

Similar to run_batch, but analyzes the memory requirement of a simulation at different times.

First, the specified script file will be run using the specified parameters. Then at each of the specified times, the given analysis_fn (which calls allsizes_mb() by default) is run. The output is labeled with the script file, time, and parameters so that results from different runs can be compared.