Explain retrieving session statistics (#1961)

Explain retrieving session statistics in python. Based on the discussion here: https://github.com/arvidn/libtorrent/issues/1953
This commit is contained in:
Chengxin Ma 2017-05-01 18:05:24 +02:00 committed by Arvid Norberg
parent 4cf2bedde9
commit e88ce93eab
1 changed files with 4 additions and 0 deletions

View File

@ -107,6 +107,10 @@ To get a python dictionary of the settings, call ``session::get_settings``.
.. _`library reference`: reference.html
Retrieving session statistics in Python is more convenient than that in C++.
The statistics are stored as an array in ``session_stats_alert``, which will be posted after calling ``post_session_stats()`` in the ``session`` object.
In order to interpret the statistics array, in C++ it is required to call ``session_stats_metrics()`` to get the indices of these metrics, while in Python it can be done using ``session_stats_alert.values["NAME_OF_METRIC"]``, where ``NAME_OF_METRIC`` is the name of a metric.
For an example python program, see ``client.py`` in the ``bindings/python``
directory.