Locked History Actions


How To Profile a Python Script

Run the program using cProfile to log data to profile.out as it runs:

python -m cProfile -o profile.out <myprogram> <myargs> ...

Load the profile data in an interactive python session:

import pstats
p = pstats.Stats('profile.out')

Get a list of the top ten routines where the time is being spent:


More details here.