MCPcopy Create free account
hub / github.com/ElementsProject/elements / updateRates

Method updateRates

src/qt/trafficgraphwidget.cpp:122–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void 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
153void TrafficGraphWidget::setGraphRange(std::chrono::minutes new_range)
154{

Callers

nothing calls this directly

Calls 4

getTotalBytesRecvMethod · 0.80
getTotalBytesSentMethod · 0.80
sizeMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected