| 58 | } |
| 59 | |
| 60 | int ServerInfo::averageSpeed() const |
| 61 | { |
| 62 | int count = 0; |
| 63 | int total = 0; |
| 64 | |
| 65 | for (const auto& s : m_lastDownloads) { |
| 66 | if (s > 0) { |
| 67 | ++count; |
| 68 | total += s; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if (count > 0) { |
| 73 | return static_cast<double>(total) / count; |
| 74 | } |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | void ServerInfo::addDownload(int bytesPerSecond) |
| 80 | { |