diff options
author | Explorer09 <explorer09@gmail.com> | 2023-11-23 03:06:30 +0800 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-11-24 09:51:25 +0100 |
commit | 1d3a823d5d87c0966b3001f7ee18285e15506806 (patch) | |
tree | be4e9f3ef4eaed30146f0b196e484539dc9aad92 | |
parent | fda3d1026187387b71ff056828c5a22156cdc8da (diff) |
Change NetworkIOMeter value unit from KiB/s to bytes/second
Improve precisions when drawing in bar meter mode.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
-rw-r--r-- | NetworkIOMeter.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c index ac453d89..ea7ffba2 100644 --- a/NetworkIOMeter.c +++ b/NetworkIOMeter.c @@ -70,12 +70,11 @@ static void NetworkIOMeter_updateValues(Meter* this) { if (data.bytesReceived > cached_rxb_total) { diff = data.bytesReceived - cached_rxb_total; diff = (1000 * diff) / passedTimeInMs; /* convert to B/s */ - diff /= ONE_K; /* convert to KiB/s */ cached_rxb_diff = diff; } else { cached_rxb_diff = 0; } - Meter_humanUnit(cached_rxb_diff_str, cached_rxb_diff, sizeof(cached_rxb_diff_str)); + Meter_humanUnit(cached_rxb_diff_str, cached_rxb_diff / ONE_K, sizeof(cached_rxb_diff_str)); if (data.packetsReceived > cached_rxp_total) { diff = data.packetsReceived - cached_rxp_total; @@ -88,12 +87,11 @@ static void NetworkIOMeter_updateValues(Meter* this) { if (data.bytesTransmitted > cached_txb_total) { diff = data.bytesTransmitted - cached_txb_total; diff = (1000 * diff) / passedTimeInMs; /* convert to B/s */ - diff /= ONE_K; /* convert to KiB/s */ cached_txb_diff = diff; } else { cached_txb_diff = 0; } - Meter_humanUnit(cached_txb_diff_str, cached_txb_diff, sizeof(cached_txb_diff_str)); + Meter_humanUnit(cached_txb_diff_str, cached_txb_diff / ONE_K, sizeof(cached_txb_diff_str)); if (data.packetsTransmitted > cached_txp_total) { diff = data.packetsTransmitted - cached_txp_total; |