| 120 | } |
| 121 | |
| 122 | void TrafficGraphWidget::updateRates() |
| 123 | { |
| 124 | if(!clientModel) return; |
| 125 | |
| 126 | quint64 bytesIn = clientModel->node().getTotalBytesRecv(), |
| 127 | bytesOut = clientModel->node().getTotalBytesSent(); |
| 128 | float in_rate_kilobytes_per_sec = static_cast<float>(bytesIn - nLastBytesIn) / timer->interval(); |
| 129 | float out_rate_kilobytes_per_sec = static_cast<float>(bytesOut - nLastBytesOut) / timer->interval(); |
| 130 | vSamplesIn.push_front(in_rate_kilobytes_per_sec); |
| 131 | vSamplesOut.push_front(out_rate_kilobytes_per_sec); |
| 132 | nLastBytesIn = bytesIn; |
| 133 | nLastBytesOut = bytesOut; |
| 134 | |
| 135 | while(vSamplesIn.size() > DESIRED_SAMPLES) { |
| 136 | vSamplesIn.pop_back(); |
| 137 | } |
| 138 | while(vSamplesOut.size() > DESIRED_SAMPLES) { |
| 139 | vSamplesOut.pop_back(); |
| 140 | } |
| 141 | |
| 142 | float tmax = 0.0f; |
| 143 | for (const float f : vSamplesIn) { |
| 144 | if(f > tmax) tmax = f; |
| 145 | } |
| 146 | for (const float f : vSamplesOut) { |
| 147 | if(f > tmax) tmax = f; |
| 148 | } |
| 149 | fMax = tmax; |
| 150 | update(); |
| 151 | } |
| 152 | |
| 153 | void TrafficGraphWidget::setGraphRange(std::chrono::minutes new_range) |
| 154 | { |
nothing calls this directly
no test coverage detected