========
SnakeViz
========
This library is interesting because it give a nice output in the form of dynamic html graphs.
One example is better than a thousand words, in Jupyter Notebook:
.. code-block:: python
# call this typically on your first cell
%load_ext snakeviz
%snakeviz single_line_method_profiling()
# or you may want to profile a whole block of code
%%snakeviz
dope_list = [1,2,3,4,5,6]
for i in list:
perform_complex_operation(i)
This will open the result embedded directly in the notebook. If you want to see it in your favorite navigator, use
``%snakeviz --new-tab`` or even efficient ``%snakeviz -t``.
That's it, this way you'll receive the output shown in the two following pictures. First one is the graphical view
(which is totally interactive when in html mode) and a result table, which is dynamic according to the graphical view.
.. figure:: img/icicle.png
:align: center
:alt: Icycle
:width: 100%
Source: `SnakeViz documentation `__
.. figure:: img/stats_table.png
:align: center
:alt: Result table
:width: 100%
Source: `SnakeViz documentation `__
.. note::
Don't take the time displayed as real elapsed time but more as a relative reference.
:tag:`profiling`
:tag:`snakeviz`
:tag:`Python`