| 35 | } |
| 36 | |
| 37 | void PacketStatCollector::calculate() { |
| 38 | int64_t currentTime = Time::monotonicMilliseconds(); |
| 39 | float elapsedTime = (currentTime - m_lastMixTime) / 1000.0f; |
| 40 | if (elapsedTime >= m_calculationWindow) { |
| 41 | m_lastMixTime = currentTime; |
| 42 | m_stats.worstPacketSize = 0; |
| 43 | |
| 44 | for (auto& pair : m_unmixed) { |
| 45 | if (pair.second > m_stats.worstPacketSize) { |
| 46 | m_stats.worstPacketType = pair.first; |
| 47 | m_stats.worstPacketSize = pair.second; |
| 48 | } |
| 49 | |
| 50 | m_stats.packetBytesPerSecond[pair.first] = round(pair.second / elapsedTime); |
| 51 | } |
| 52 | m_stats.bytesPerSecond = round(float(m_totalBytes) / elapsedTime); |
| 53 | m_totalBytes = 0; |
| 54 | m_unmixed.clear(); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | Maybe<PacketStats> PacketSocket::incomingStats() const { |
| 59 | return {}; |
no test coverage detected