How to calculate the CPU time consumption and memory consuption of any python program in Linux

gene tani gene.tani at gmail.com
Sat Dec 24 13:18:36 EST 2005


MrJean1 wrote:
> For CPU time usage, see the standard time module
>
>   <http://docs.python.org/lib/module-time.html>
>
> specifically the time.clock() function.  For memory usage see
>
>   <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286222>
>
>
> /Jean Brouwers

there was a good long discussion about memory profiling, incluindg some
things that seem to work but don't actually. start here:
http://mail.python.org/pipermail/python-list/2005-November/310121.html

the old school way is to use funcs like
sys.getobjects()
sys.gettotalrefcount() ## Py_REF_DEBUG build
gc.get_objects()
gc.get_referrers('')

and look here:
http://evanjones.ca/python-memory.html
http://codespeak.net/svn/user/nick8325/sizer/
http://pysizer.8325.org/
http://www.softwareverify.com/
http://www.egenix.com/files/python/eGenix-mx-Extensions.html#mxTools

and somebody suggested throttling back memory using "limit vmemory
10000 "




More information about the Python-list mailing list