I am using Python\'s hotshot profiler: http://docs.python.org/2/library/hotshot.html
It shows how to print the stats:
stats.print_stats(20)
stats.dump_stats(path/to/file)