Pythonでkcachegrindを使ったパフォーマンス分析

Pythonでは, cProfileを使えばパフォーマンス分析ができるっぽいけど, やっぱりGUIでやりたいよねってことで, kcachegrindでパフォーマンス分析結果を見る方法を調べた.
このページを見れば, だいたい載ってる.

必要なのは

  • kcachegrind
  • pyprof2calltree

前者はaptで, 後者はeasy_installでインストールする.

後は,

python -m cProfile -o profile_data.pyprof script_to_profile.py
pyprof2calltree -i profile_data.pyprof -k

でOK.