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)
You can use the library: pstats_print2list https://pypi.python.org/pypi/pstats_print2list
pip install pstats_print2list
And usage:
from pstats_print2list import get_pstats_print2list, print_pstats_list
fname_stats = 'my_profiling_out.stats'
pstats_list = get_pstats_print2list(
os.path.expanduser(fname_stats),
filter_fnames=['myfile1.py', 'myfile2.py', 'root_path1'],
exclude_fnames=['dontshow.py', 'path_dont_show'],
sort='cumulative',
limit=5,
)
print_pstats_list(pstats_list)