5#include <QtCore/QtGlobal>
20 using Clock = std::function<quint64()>;
36 double kBps()
const {
return _currentRate / 1024.0; }
49 quint64 _windowStartedUs = 0;
50 quint64 _totalBytes = 0;
51 qsizetype _windowBytes = 0;
52 double _currentRate = 0.0;
53 bool _rateUpdated =
false;
55 static constexpr quint64 kWindowUs = 1000000;
void reset()
Reset all counters and restart the rate window.
std::function< quint64()> Clock
Monotonic microseconds, injectable for deterministic window tests.
double kBps() const
Current data rate in KB/s.
void recordBytes(qsizetype bytes)
Record incoming/outgoing bytes. Call whenever data passes through.
void refresh()
Advance the rate window without changing cumulative bytes.
void resetRate()
Zero the rate and restart its window; cumulative bytes are kept.
double bytesPerSec() const
Rate of the last completed window, in bytes/sec.
quint64 totalBytes() const
Total bytes recorded since construction or last reset.