Merge pull request #13023 from SimonWalton-HiFi/connection-stats-dump

Add a utility function to dump ConnectionStats
This commit is contained in:
Stephen Birarda 2018-05-04 10:19:25 -07:00 committed by GitHub
commit 8c6d83ad67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View file

@ -9,6 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QtCore/QDebug>
#include "ConnectionStats.h"
using namespace udt;
@ -112,3 +113,31 @@ void ConnectionStats::recordPacketSendPeriod(int sample) {
_currentSample.packetSendPeriod = sample;
_total.packetSendPeriod = (int)((_total.packetSendPeriod * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
QDebug& operator<<(QDebug&& debug, const udt::ConnectionStats::Stats& stats) {
debug << "Connection stats:\n";
#define HIFI_LOG_EVENT(x) << " " #x " events: " << stats.events[ConnectionStats::Stats::Event::x] << "\n"
debug
HIFI_LOG_EVENT(SentACK)
HIFI_LOG_EVENT(ReceivedACK)
HIFI_LOG_EVENT(ProcessedACK)
HIFI_LOG_EVENT(SentLightACK)
HIFI_LOG_EVENT(ReceivedLightACK)
HIFI_LOG_EVENT(SentACK2)
HIFI_LOG_EVENT(ReceivedACK2)
HIFI_LOG_EVENT(SentNAK)
HIFI_LOG_EVENT(ReceivedNAK)
HIFI_LOG_EVENT(SentTimeoutNAK)
HIFI_LOG_EVENT(ReceivedTimeoutNAK)
HIFI_LOG_EVENT(Retransmission)
HIFI_LOG_EVENT(Duplicate)
;
#undef HIFI_LOG_EVENT
debug << " Sent packets: " << stats.sentPackets;
debug << "\n Received packets: " << stats.receivedPackets;
debug << "\n Sent util bytes: " << stats.sentUtilBytes;
debug << "\n Sent bytes: " << stats.sentBytes;
debug << "\n Received bytes: " << stats.receivedBytes << "\n";
return debug;
}

View file

@ -101,4 +101,7 @@ private:
}
class QDebug;
QDebug& operator<<(QDebug&& debug, const udt::ConnectionStats::Stats& stats);
#endif // hifi_ConnectionStats_h