With cProfile you can also profile existing programs, without making any separate profiling script. Just run program with profiler
python -m cProfile -o profile_data.pyprof script_to_profile.py
and open profile data in kcachegrind with pyprof2calltree, whose -k switch automatically opens data in kcachegrind
pyprof2calltree -i profile_data.pyprof -k
For example profiling whole paster server and webapp would be done like this
python -m cProfile -o pyprof.out `which paster` serve development.ini
pyprof2calltree can be installed with easy_install.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…