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

  • Thread starter Shahriar Shamil Uulu
  • Start date
S

Shahriar Shamil Uulu

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 ...
 
G

gene tani

MrJean1 said:
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 "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top