[Client] Rename LagMonitor constants to SCREAMING_SNAKE_CASE

Took 15 minutes
This commit is contained in:
Lukas Brübach 2026-08-23 00:14:06 +02:00
parent 8a9635949f
commit 45fe8b57a5
2 changed files with 9 additions and 9 deletions

View file

@ -5,7 +5,7 @@
LagMonitor::LagMonitor(QObject *parent) : QObject(parent)
{
timer = new QTimer(this);
timer->setInterval(TickIntervalMs);
timer->setInterval(TICK_INTERVAL_MS);
connect(timer, &QTimer::timeout, this, &LagMonitor::checkTick);
tickClock.start();
timer->start();
@ -25,7 +25,7 @@ void LagMonitor::checkTick()
{
const qint64 gap = tickClock.restart();
if (gap <= StallThresholdMs) {
if (gap <= STALL_THRESHOLD_MS) {
return;
}
@ -34,10 +34,10 @@ void LagMonitor::checkTick()
record.durationMs = gap;
stalls.append(record);
while (stalls.size() > MaxRecordedStalls) {
while (stalls.size() > MAX_RECORDED_STALLS) {
stalls.removeFirst();
}
qCWarning(LagMonitorLog, "Event loop stalled for %lld ms (threshold: %d ms)", static_cast<long long>(gap),
StallThresholdMs);
STALL_THRESHOLD_MS);
}

View file

@ -19,7 +19,7 @@ class QTimer;
/**
* @brief Detects main-thread event loop stalls ("UI freezes") from the inside.
*
* A timer is expected to fire every TickIntervalMs of wall time. When the
* A timer is expected to fire every TICK_INTERVAL_MS of wall time. When the
* observed gap greatly exceeds that interval, some other task blocked the
* event loop for roughly the overshooting duration. This is what separates
* "my client froze" from "the network is lagging" in user reports.
@ -38,9 +38,9 @@ public:
qint64 durationMs = 0; ///< approximate length of the freeze
};
static constexpr int TickIntervalMs = 500;
static constexpr int StallThresholdMs = 2000;
static constexpr int MaxRecordedStalls = 32;
static constexpr int TICK_INTERVAL_MS = 500;
static constexpr int STALL_THRESHOLD_MS = 2000;
static constexpr int MAX_RECORDED_STALLS = 32;
explicit LagMonitor(QObject *parent = nullptr);
@ -48,7 +48,7 @@ public:
* @brief Stalls recorded during this session, oldest first.
*
* Intended consumers are log output and the diagnostics export. The list
* holds at most MaxRecordedStalls entries.
* holds at most MAX_RECORDED_STALLS entries.
*/
QList<StallRecord> recentStalls() const;