Here is some pseudocode showing what I'm hoping to do:
# Get a cProfile object with the profile information of my function.
# This syntax doesn't work and this is the first part I need help
with.
p = cProfile.run('(a,b,c)=myFunc(x,y,z)')
# Get the process time. The timeit.clock() function would give me
process time
# but it doesn't allow me to access the return arguments afterward so
I can't use it.
# The syntax of the next line doesn't work but this is an example of
what I hope to do.
top_entry = p.getstats()[0]
cum_time = top_entry[3] # totaltime
# Now, log all this info to a CSV file. (No help needed here.)
csv_file.writerow([a,b,c,x,y,z,cum_time])
Once this works, I will wrap the above code in a loop which iterates
through thousands of combinations of the parameters x,y,z.
Thanks in advance for your help.
Reg
I think what you need to look at is the documentation for the various
Python profilers:
http://docs.python.org/library/profile.html
From what I can see, it looks like cProfile can log to a file and you
use the pstats module to review the data generated. That link also
links to the hotshot profiler, which looks like it's even simpler to
use.
You might also want to check out the logging module.
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
PyCon 2010 Atlanta Feb 19-21 http://us.pycon.org/