MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / calculate

Method calculate

source/game/StarNetPacketSocket.cpp:37–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void 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
58Maybe<PacketStats> PacketSocket::incomingStats() const {
59 return {};

Callers 3

statsMethod · 0.45
lightingCalcMethod · 0.45
lightLevelFunction · 0.45

Calls 2

roundFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected