diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-04-01 17:32:01 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-04-01 17:32:01 +0200 |
commit | 1ed6441925f424b9b2b280f1fa498f3d22dbb890 (patch) | |
tree | 5305e4c1260c1e1cf89bc48bc7e3575eb8130b94 /contrib/epee/src | |
parent | Merge pull request #5326 (diff) | |
parent | New interactive daemon command 'print_net_stats': Global traffic stats (diff) | |
download | monero-1ed6441925f424b9b2b280f1fa498f3d22dbb890.tar.xz |
Merge pull request #5327
c23ea796 New interactive daemon command 'print_net_stats': Global traffic stats (rbrunner7)
Diffstat (limited to 'contrib/epee/src')
-rw-r--r-- | contrib/epee/src/network_throttle-detail.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp index f89e7aec0..72544cbf6 100644 --- a/contrib/epee/src/network_throttle-detail.cpp +++ b/contrib/epee/src/network_throttle-detail.cpp @@ -136,6 +136,8 @@ network_throttle::network_throttle(const std::string &nameshort, const std::stri m_target_speed = 16 * 1024; // other defaults are probably defined in the command-line parsing code when this class is used e.g. as main global throttle m_last_sample_time = 0; m_history.resize(m_window_size); + m_total_packets = 0; + m_total_bytes = 0; } void network_throttle::set_name(const std::string &name) @@ -192,6 +194,8 @@ void network_throttle::_handle_trafic_exact(size_t packet_size, size_t orginal_s calculate_times_struct cts ; calculate_times(packet_size, cts , false, -1); calculate_times_struct cts2; calculate_times(packet_size, cts2, false, 5); m_history.front().m_size += packet_size; + m_total_packets++; + m_total_bytes += packet_size; std::ostringstream oss; oss << "["; for (auto sample: m_history) oss << sample.m_size << " "; oss << "]" << std::ends; std::string history_str = oss.str(); @@ -352,6 +356,12 @@ double network_throttle::get_current_speed() const { return bytes_transferred / ((m_history.size() - 1) * m_slot_size); } +void network_throttle::get_stats(uint64_t &total_packets, uint64_t &total_bytes) const { + total_packets = m_total_packets; + total_bytes = m_total_bytes; +} + + } // namespace } // namespace |