To add on to https://stackoverflow.com/a/582337/1070617,
I wrote this module that allows you to use cProfile and view its output easily. More here: https://github.com/ymichael/cprofilev
$ python -m cprofilev /your/python/program
# Go to http://localhost:4000 to view collected statistics.
Also see: http://ymichael.com/2014/03/08/profiling-python-with-cprofile.html on how to make sense of the collected statistics.