From: sfan5 Date: Fri, 15 May 2020 13:12:37 +0000 (+0200) Subject: Client: Add sum and average to packetcounter X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=be38a44ffe2355d909774923a517d8b37f932dfe;p=oweals%2Fminetest.git Client: Add sum and average to packetcounter --- diff --git a/src/client/client.cpp b/src/client/client.cpp index 941fc203d..c03c062c6 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -64,6 +64,14 @@ extern gui::IGUIEnvironment* guienv; Utility classes */ +u32 PacketCounter::sum() const +{ + u32 n = 0; + for (const auto &it : m_packets) + n += it.second; + return n; +} + void PacketCounter::print(std::ostream &o) const { for (const auto &it : m_packets) { @@ -357,9 +365,11 @@ void Client::step(float dtime) if(counter <= 0.0f) { counter = 30.0f; + u32 sum = m_packetcounter.sum(); + float avg = sum / counter; - infostream << "Client packetcounter (" << m_packetcounter_timer - << "s):"< m_packets; + std::map m_packets; }; class ClientScripting;