aboutsummaryrefslogtreecommitdiffstats
path: root/DiskIOMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2023-02-05 04:25:56 +0100
committerDaniel Lange <DLange@git.local>2023-02-05 04:25:56 +0100
commitf288666edc9180a2e81e6655951878124f321df6 (patch)
treeda70bf44b2423f6f8e9a070c063fed79d190b489 /DiskIOMeter.c
parent937052b231259a47d881d539ad5748245ef55b99 (diff)
downloaddebian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.gz
debian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.bz2
debian_htop-f288666edc9180a2e81e6655951878124f321df6.zip
New upstream version 3.2.2upstream/3.2.2
Diffstat (limited to 'DiskIOMeter.c')
-rw-r--r--DiskIOMeter.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/DiskIOMeter.c b/DiskIOMeter.c
index 12c87de..adab8f7 100644
--- a/DiskIOMeter.c
+++ b/DiskIOMeter.c
@@ -64,7 +64,8 @@ static void DiskIOMeter_updateValues(Meter* this) {
if (data.totalBytesRead > cached_read_total) {
diff = data.totalBytesRead - cached_read_total;
- diff /= 1024; /* Meter_humanUnit() expects unit in kilo */
+ diff = (1000 * diff) / passedTimeInMs; /* convert to B/s */
+ diff /= ONE_K; /* convert to KiB/s */
cached_read_diff = (uint32_t)diff;
} else {
cached_read_diff = 0;
@@ -73,7 +74,8 @@ static void DiskIOMeter_updateValues(Meter* this) {
if (data.totalBytesWritten > cached_write_total) {
diff = data.totalBytesWritten - cached_write_total;
- diff /= 1024; /* Meter_humanUnit() expects unit in kilo */
+ diff = (1000 * diff) / passedTimeInMs; /* convert to B/s */
+ diff /= ONE_K; /* convert to KiB/s */
cached_write_diff = (uint32_t)diff;
} else {
cached_write_diff = 0;
@@ -104,7 +106,7 @@ static void DiskIOMeter_updateValues(Meter* this) {
char bufferRead[12], bufferWrite[12];
Meter_humanUnit(bufferRead, cached_read_diff, sizeof(bufferRead));
Meter_humanUnit(bufferWrite, cached_write_diff, sizeof(bufferWrite));
- snprintf(this->txtBuffer, sizeof(this->txtBuffer), "%sB %sB %.1f%%", bufferRead, bufferWrite, cached_utilisation_diff);
+ snprintf(this->txtBuffer, sizeof(this->txtBuffer), "r:%siB/s w:%siB/s %.1f%%", bufferRead, bufferWrite, cached_utilisation_diff);
}
static void DiskIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
@@ -132,10 +134,12 @@ static void DiskIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out)
RichString_appendAscii(out, CRT_colors[METER_TEXT], " read: ");
Meter_humanUnit(buffer, cached_read_diff, sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_VALUE_IOREAD], buffer);
+ RichString_appendAscii(out, CRT_colors[METER_VALUE_IOREAD], "iB/s");
RichString_appendAscii(out, CRT_colors[METER_TEXT], " write: ");
Meter_humanUnit(buffer, cached_write_diff, sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_VALUE_IOWRITE], buffer);
+ RichString_appendAscii(out, CRT_colors[METER_VALUE_IOWRITE], "iB/s");
}
const MeterClass DiskIOMeter_class = {

© 2014-2024 Faster IT GmbH | imprint | privacy policy