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

View File

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

View File

@ -100,6 +100,22 @@ public:
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