Google Groupes n'accepte plus les nouveaux posts ni abonnements Usenet. Les contenus de l'historique resteront visibles.

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

57 vues
Accéder directement au premier message non lu

Shahriar Shamil Uulu

non lue,
24 déc. 2005, 05:10:5624/12/2005
à
Hi All,
i want to calculate the cpu time consumption and memory consuption of
any program written in python during runtime on Linux Fedora Core - 2,
P4, RAM-512 MB. Actually i have written one database program in two
ways, 1) Inprocedural way 2) in object oriented way. Now i want to
check how efficient each function, object,method and variable is. How i
can do this ?
Any help will be greatly apperciated ...
Thank you ...

MrJean1

non lue,
24 déc. 2005, 12:56:2124/12/2005
à
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

gene tani

non lue,
24 déc. 2005, 13:18:3624/12/2005
à

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 "

Shahriar Shamil Uulu

non lue,
24 déc. 2005, 13:34:3124/12/2005
à
Thank you, for your directions and advices.
shahriar ...

gene tani

non lue,
24 déc. 2005, 13:45:3424/12/2005
à

Shahriar Shamil Uulu wrote:
> Thank you, for your directions and advices.
> shahriar ...

also look:

http://spyced.blogspot.com/2005/09/how-well-do-you-know-python-part-9.html

whihc mentions twisted.python.reflect.findInstances(sys.modules, str)
and objgrep, which i didn't know about

Olivier Grisel

non lue,
24 déc. 2005, 15:29:3024/12/2005
à pytho...@python.org
gene tani a écrit :

This looks relevant too (not tested though):

http://pysizer.8325.org/

--
Olivier

0 nouveau message