Skip to content

Commit 5c9a247

Browse files
author
Simon Cahill
committed
Fixed bug in statistics page. Fixes issue #15.
1 parent 1514d60 commit 5c9a247

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/main.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ void printConnectionStatistics(const uint32_t uniqueAddresses, const uint32_t to
421421
cout << "|" << uniqueIps << "|" << acceptedConns << "|" << closedConns << "|" << aliveConns << "|";
422422

423423
if (totalTimeWasted > 0) {
424-
auto flooredSeconds = std::to_string(roundNumber(totalTimeWasted, 2));
424+
auto flooredSeconds = getHumanReadableTime(totalTimeWasted);
425425
tmp = getSpacerString(23, flooredSeconds.size());
426426
cout << tmp << flooredSeconds << string(23 - flooredSeconds.size() - tmp.size(), ' ') << '|';
427427
} if (totalBytesSent > 0) {
428-
auto totalBytes = std::to_string(totalBytesSent);
428+
auto totalBytes = getHumanReadableBytes(totalBytesSent);
429429
tmp = getSpacerString(18, totalBytes.size());
430430
cout << tmp << totalBytes << string(18 - totalBytes.size() - tmp.size(), ' ') << '|';
431431
}
@@ -514,22 +514,17 @@ void printDetailedIpStats(const vector<ConnectionDetails>& connectionList, uint3
514514
<< connection.closedConnections << string(8 - strLength - lastSpacer.size(), ' ')
515515
<< "|";
516516

517-
const auto flooredSeconds = roundNumber(connection.totalSecondsWasted, 2);
518-
strLength = (tmpString = std::to_string(flooredSeconds)).size();
517+
strLength = (tmpString = getHumanReadableTime(connection.totalSecondsWasted)).size();
519518
cout << (lastSpacer = getSpacerString(16, strLength))
520519
<< tmpString
521520
<< string(16 - strLength - lastSpacer.size(), ' ')
522521
<< "|";
523522

524523

525-
if (connection.totalBytesSent > 1024) {
526-
tmpString = std::to_string(connection.totalBytesSent / 1024) + "KiB";
527-
} else {
528-
tmpString = std::to_string(connection.totalBytesSent);
529-
}
524+
tmpString = getHumanReadableBytes(connection.totalBytesSent);
530525
strLength = tmpString.size();
531526
cout << (lastSpacer = getSpacerString(13, strLength))
532-
<< (connection.totalBytesSent > 1024 ? std::to_string(connection.totalBytesSent / 1024) + "KiB" : std::to_string(connection.totalBytesSent)) << string(13 - strLength - lastSpacer.size(), ' ')
527+
<< tmpString << string(13 - strLength - lastSpacer.size(), ' ')
533528
<< "|";
534529

535530
cout << endl;

0 commit comments

Comments
 (0)