26 , samplePeriodMs(samplePeriodMs)
29 qWarning(
"Invalid sample rate, healing to 1000ms");
30 this->samplePeriodMs = 1000;
42 qWarning(
"Bytes sent exceeds file size, ignoring sample");
49 if (bytesSent < active->bytesSent || bytesSent < inactive->bytesSent) {
50 qWarning(
"Bytes sent has decreased since last sample, ignoring sample");
54 if (now < active->timestamp || now < inactive->timestamp) {
55 qWarning(
"Sample time has gone backwards, clearing progress buffer");
60 if (inactive->timestamp == QTime()) {
61 inactive->bytesSent = bytesSent;
62 inactive->timestamp = now;
65 if (active->timestamp == QTime()) {
66 active->bytesSent = bytesSent;
67 active->timestamp = now;
73 std::swap(active, inactive);
76 active->bytesSent = bytesSent;
77 active->timestamp = now;
85 sample.timestamp = QTime();
106 const auto sampleTimeInvalid = [](
const Sample& sample) {
107 return sample.timestamp == QTime();
110 if (std::any_of(
samples.cbegin(),
samples.cend(), sampleTimeInvalid)) {
121 return (active.bytesSent - inactive.bytesSent) / double(inactive.timestamp.msecsTo(active.timestamp)) * 1000.0;
133 return std::numeric_limits<float>::infinity();