Version: 2.1.0

home

[report issue]

counters

Declared in "libtorrent/performance_counters.hpp"

holds the session-wide counters and gauges backing the session_stats_alert and session_status reporting paths. One instance lives on the session and is incremented from the network thread; reads from other threads use the lock-free operator[] overload when ATOMIC_LLONG_LOCK_FREE is set, otherwise a single shared mutex guards the whole array.

A reference to this object is passed to custom disk I/O implementations (see disk_interface and the disk_io_constructor passed via session_params), which update the disk related metrics through it. The specific counters and gauges are documented under the session statistics section.

struct counters
{
   counters () ;
   counters& operator= (counters const&) & ;
   counters (counters const&) ;
   std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
   std::int64_t operator[] (int i) const ;
   void blend_stats_counter (int c, std::int64_t value, int ratio) ;
   void set_value (int c, std::int64_t value) ;
};
[report issue]

inc_stats_counter()

std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;

increments the counter or gauge c (an index into the counter array) by value and returns the new value.

[report issue]

operator[]()

std::int64_t operator[] (int i) const ;

returns the current value of counter or gauge i (an index into the counter array).

[report issue]

set_value() blend_stats_counter()

void blend_stats_counter (int c, std::int64_t value, int ratio) ;
void set_value (int c, std::int64_t value) ;

overwrites the value of counter or gauge c (an index into the counter array). blend_stats_counter() adjusts the stat value toward the specified value, ratio specifies the percent of the new value should be influenced by value.

[report issue]

stats_metric

Declared in "libtorrent/session_stats.hpp"

describes one statistics metric from the session. For more information, see the session statistics section.

struct stats_metric
{
   char const* name;
   int value_index;
   metric_type_t type;
};
[report issue]
name
the name of the counter or gauge
[report issue]
value_index type
the index into the session stats array, where the underlying value of this counter or gauge is found. The session stats array is part of the session_stats_alert object.
[report issue]

session_stats_metrics()

Declared in "libtorrent/session_stats.hpp"

std::vector<stats_metric> session_stats_metrics ();

This free function returns the list of available metrics exposed by libtorrent's statistics API. Each metric has a name and a value index. The value index is the index into the array in session_stats_alert where this metric's value can be found when the session stats is sampled (by calling post_session_stats()).

[report issue]

find_metric_idx()

Declared in "libtorrent/session_stats.hpp"

int find_metric_idx (string_view name);

given a name of a metric, this function returns the counter index of it, or -1 if it could not be found. The counter index is the index into the values array returned by session_stats_alert.

[report issue]

enum metric_type_t

Declared in "libtorrent/session_stats.hpp"

name value description
counter 0  
gauge 1