1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
===================
Profiling PyGObject
===================
Setup
=====
General vpath build setup with jhbuild shell (x86_64):
.. code-block:: bash
mkdir _build
cd _build
export PYTHON=`which python3.3`
jhbuild shell
../configure --prefix=$JHBUILD_PREFIX --libdir=$JHBUILD_LIBDIR --with-python=$PYTHON
make
Devise a simple script to profile (myproftest.py):
.. code-block:: python
from gi.repository import Gtk
model = Gtk.ListStore(str, str, str, int, int, int)
columns = [0, 1, 2, 3, 4, 5]
row = ['a'*16, 'b'*16, 'c'*16, 1, 2, 3]
for i in range(100000):
model.insert_with_valuesv(-1, columns, row)
Python Profile
==============
Use cProfile and kcachegrind (via pyprof2calltree):
.. code-block:: bash
PROFTEST=myproftest
$PYTHON -m cProfile -o $PROFTEST.pyprof $PROFTEST.py
pyprof2calltree -i $PROFTEST.pyprof -k
C Extension (callgrind)
=======================
.. code-block:: bash
PROFTEST=myproftest
valgrind --tool=callgrind --callgrind-out-file=$PROFTEST.callgrind $PYTHON $PROFTEST.py
kcachegrind $PROFTEST.callgrind
C Extension (gperftools)
========================
Google PerfTools https://code.google.com/p/gperftools
.. code-block:: bash
PROFTEST=myproftest
$PYTHON -m yep -o $PROFTEST.py.prof $PROFTEST.py
google-pprof --callgrind $PYTHON $PROFTEST.py.prof > $PROFTEST.callgrind
kcachegrind $PROFTEST.callgrind
|