GUI changes to display avg latency

At this time we only show per-guid latency aggregated across all ports
This commit is contained in:
Srivats P 2023-04-04 13:19:53 +05:30
parent 3e3b5144aa
commit 8ecbe78ddd
3 changed files with 37 additions and 1 deletions

View File

@ -51,6 +51,7 @@ enum {
kAvgRxFrameRate, kAvgRxFrameRate,
kAvgTxBitRate, kAvgTxBitRate,
kAvgRxBitRate, kAvgRxBitRate,
kAvgLatency,
kMaxAggrStreamStats kMaxAggrStreamStats
}; };
static QStringList aggrStatTitles = QStringList() static QStringList aggrStatTitles = QStringList()
@ -61,7 +62,8 @@ static QStringList aggrStatTitles = QStringList()
<< "Avg\nTx PktRate" << "Avg\nTx PktRate"
<< "Avg\nRx PktRate" << "Avg\nRx PktRate"
<< "Avg\nTx BitRate" << "Avg\nTx BitRate"
<< "Avg\nRx BitRate"; << "Avg\nRx BitRate"
<< "Avg\nLatency";
static const uint kAggrGuid = 0xffffffff; static const uint kAggrGuid = 0xffffffff;
@ -184,6 +186,12 @@ QVariant StreamStatsModel::data(const QModelIndex &index, int role) const
(aggrGuidStats_.value(guid).rxBytes (aggrGuidStats_.value(guid).rxBytes
+ 24 * aggrGuidStats_.value(guid).rxPkts) * 8 + 24 * aggrGuidStats_.value(guid).rxPkts) * 8
/ aggrGuidStats_.value(guid).txDuration); / aggrGuidStats_.value(guid).txDuration);
case kAvgLatency:
return aggrGuidStats_.value(guid).latencyCount <= 0
|| aggrGuidStats_.value(guid).latencySum <= 0 ? QString("-") :
XLocale().toTimeIntervalString(
aggrGuidStats_.value(guid).latencySum
/ aggrGuidStats_.value(guid).latencyCount);
default: default:
break; break;
}; };
@ -258,6 +266,7 @@ void StreamStatsModel::appendStreamStatsList(
ss.txPkts = s.tx_pkts(); ss.txPkts = s.tx_pkts();
ss.rxBytes = s.rx_bytes(); ss.rxBytes = s.rx_bytes();
ss.txBytes = s.tx_bytes(); ss.txBytes = s.tx_bytes();
ss.rxLatency = s.delay();
aggrPort.rxPkts += ss.rxPkts; aggrPort.rxPkts += ss.rxPkts;
aggrPort.txPkts += ss.txPkts; aggrPort.txPkts += ss.txPkts;
@ -271,6 +280,10 @@ void StreamStatsModel::appendStreamStatsList(
aggrGuid.txBytes += ss.txBytes; aggrGuid.txBytes += ss.txBytes;
if (s.tx_duration() > aggrGuid.txDuration) if (s.tx_duration() > aggrGuid.txDuration)
aggrGuid.txDuration = s.tx_duration(); // XXX: use largest or avg? aggrGuid.txDuration = s.tx_duration(); // XXX: use largest or avg?
if (ss.rxLatency) {
aggrGuid.latencySum += ss.rxLatency;
aggrGuid.latencyCount++;
}
aggrAggr.rxPkts += ss.rxPkts; aggrAggr.rxPkts += ss.rxPkts;
aggrAggr.txPkts += ss.txPkts; aggrAggr.txPkts += ss.txPkts;
@ -279,6 +292,10 @@ void StreamStatsModel::appendStreamStatsList(
aggrAggr.txBytes += ss.txBytes; aggrAggr.txBytes += ss.txBytes;
if (aggrGuid.txDuration > aggrAggr.txDuration) if (aggrGuid.txDuration > aggrAggr.txDuration)
aggrAggr.txDuration = aggrGuid.txDuration; aggrAggr.txDuration = aggrGuid.txDuration;
if (ss.rxLatency) {
aggrAggr.latencySum += ss.rxLatency;
aggrAggr.latencyCount++;
}
if (!portList_.contains(pgp)) if (!portList_.contains(pgp))
portList_.append(pgp); portList_.append(pgp);

View File

@ -57,6 +57,7 @@ private:
quint64 txPkts; quint64 txPkts;
quint64 rxBytes; quint64 rxBytes;
quint64 txBytes; quint64 txBytes;
quint64 rxLatency;
}; };
struct AggrGuidStats { struct AggrGuidStats {
quint64 rxPkts; quint64 rxPkts;
@ -65,6 +66,8 @@ private:
quint64 txBytes; quint64 txBytes;
qint64 pktLoss; qint64 pktLoss;
double txDuration; double txDuration;
quint64 latencySum;
uint latencyCount;
}; };
QList<Guid> guidList_; QList<Guid> guidList_;
QList<PortGroupPort> portList_; QList<PortGroupPort> portList_;

View File

@ -100,6 +100,22 @@ public:
return QObject::tr("%L1 bps").arg(bps, 0, 'f', 4); return QObject::tr("%L1 bps").arg(bps, 0, 'f', 4);
} }
QString toTimeIntervalString(qint64 nanosecs) const
{
QString text;
if (nanosecs >= 1e9)
return QObject::tr("%L1 s").arg(nanosecs/1e9, 0, 'f', 3);
if (nanosecs >= 1e6)
return QObject::tr("%L1 ms").arg(nanosecs/1e6, 0, 'f', 3);
if (nanosecs >= 1e3)
return QObject::tr("%L1 us").arg(nanosecs/1e3, 0, 'f', 3);
return QObject::tr("%L1 ns").arg(nanosecs);
}
}; };
#endif #endif