Profiling programs/scripts?

S

skanemupp

how do i profile a program? i found out that there are some profilers
included in the standard library but couldnt really figure out how to
access/use them
 
M

Mike Driscoll

how do i profile a program? i found out that there are some profilers
included in the standard library but couldnt really figure out how to
access/use them

Are you talking about using PyChecker or nose or what? In other words,
do you want to check your script for errors, documentation issues,
compliance with PEPs or something else? Maybe you mean introspection?

If the latter, here are a few links on the subject:

http://www.ibm.com/developerworks/library/l-pyint.html
http://www.diveintopython.org/power_of_introspection/index.html
http://www.ginstrom.com/scribbles/2007/10/24/python-introspection-with-the-inspect-module/

If you want to do code coverage, PEPs stuff or checking for errors,
use PyChecker and PyLint or nose.

See the following for more info:

http://www.logilab.org/857
http://pychecker.sourceforge.net/
http://somethingaboutorange.com/mrl/projects/nose/

Mike
 
A

Aaron Watters

how do i profile a program? i found out that there are some profilers
included in the standard library but couldnt really figure out how to
access/use them

I put this at the bottom of my main module:

=== cut
if __name__=="__main__":
try:
from cProfile import run
except:
from profile import run
run("tests()")
=== cut

Here tests() is the function I want to profile. The cProfile
module, when available is better than the older profile module,
but it's only available in very recent Python installations.
The profile "run" function will run the tests function and print
a report on the timings and counts it found.

More info here:
http://docs.python.org/lib/profile.html

-- Aaron Watters
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=emulate+perl
 

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

Similar Threads

Scripts 3
Bash scripts for web apps 1
FAQ 3.6 How do I profile my Perl programs? 0
Problem with codewars. 5
profiling qt programs 0
Thread Profiling 1
The end of maintenance 1
Profiling python on OSX? 0

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top