2020-08-20 03:59:41 +00:00
|
|
|
/*
|
|
|
|
htop - PressureStallMeter.c
|
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
|
|
|
(C) 2019 Ran Benita
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2020-08-20 03:59:41 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PressureStallMeter.h"
|
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include <stdbool.h>
|
2020-08-20 03:59:41 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2020-09-19 18:22:34 +00:00
|
|
|
#include "CRT.h"
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "Meter.h"
|
|
|
|
#include "Object.h"
|
2020-09-19 18:22:34 +00:00
|
|
|
#include "Platform.h"
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "RichString.h"
|
2020-10-14 18:21:09 +00:00
|
|
|
#include "XUtils.h"
|
2020-09-19 18:22:34 +00:00
|
|
|
|
2020-08-20 03:59:41 +00:00
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
static const int PressureStallMeter_attributes[] = {
|
2020-11-29 14:27:51 +00:00
|
|
|
PRESSURE_STALL_TEN,
|
|
|
|
PRESSURE_STALL_SIXTY,
|
|
|
|
PRESSURE_STALL_THREEHUNDRED
|
2020-08-20 03:59:41 +00:00
|
|
|
};
|
|
|
|
|
2020-11-24 17:31:03 +00:00
|
|
|
static void PressureStallMeter_updateValues(Meter* this, char* buffer, size_t len) {
|
2020-10-31 21:14:27 +00:00
|
|
|
const char* file;
|
|
|
|
if (strstr(Meter_name(this), "CPU")) {
|
|
|
|
file = "cpu";
|
|
|
|
} else if (strstr(Meter_name(this), "IO")) {
|
|
|
|
file = "io";
|
|
|
|
} else {
|
|
|
|
file = "memory";
|
|
|
|
}
|
2020-08-20 03:59:41 +00:00
|
|
|
|
2020-10-31 21:14:27 +00:00
|
|
|
bool some;
|
|
|
|
if (strstr(Meter_name(this), "Some")) {
|
|
|
|
some = true;
|
|
|
|
} else {
|
|
|
|
some = false;
|
|
|
|
}
|
2020-08-20 03:59:41 +00:00
|
|
|
|
2020-10-31 21:14:27 +00:00
|
|
|
Platform_getPressureStall(file, some, &this->values[0], &this->values[1], &this->values[2]);
|
2020-12-08 14:55:26 +00:00
|
|
|
|
|
|
|
/* only print bar for ten (not sixty and threehundred), cause the sum is meaningless */
|
|
|
|
this->curItems = 1;
|
|
|
|
|
|
|
|
xSnprintf(buffer, len, "%s %s %5.2lf%% %5.2lf%% %5.2lf%%", some ? "some" : "full", file, this->values[0], this->values[1], this->values[2]);
|
2020-08-20 03:59:41 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 10:28:11 +00:00
|
|
|
static void PressureStallMeter_display(const Object* cast, RichString* out) {
|
|
|
|
const Meter* this = (const Meter*)cast;
|
2020-08-20 03:59:41 +00:00
|
|
|
char buffer[20];
|
2020-12-08 14:55:26 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[0]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_writeAscii(out, CRT_colors[PRESSURE_STALL_TEN], buffer);
|
2020-12-08 14:55:26 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[1]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[PRESSURE_STALL_SIXTY], buffer);
|
2020-12-08 14:55:26 +00:00
|
|
|
xSnprintf(buffer, sizeof(buffer), "%5.2lf%% ", this->values[2]);
|
2020-12-04 13:44:57 +00:00
|
|
|
RichString_appendAscii(out, CRT_colors[PRESSURE_STALL_THREEHUNDRED], buffer);
|
2020-08-20 03:59:41 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
const MeterClass PressureStallCPUSomeMeter_class = {
|
2020-08-20 03:59:41 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = PressureStallMeter_display,
|
|
|
|
},
|
|
|
|
.updateValues = PressureStallMeter_updateValues,
|
|
|
|
.defaultMode = TEXT_METERMODE,
|
|
|
|
.maxItems = 3,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = PressureStallMeter_attributes,
|
|
|
|
.name = "PressureStallCPUSome",
|
2020-11-29 14:27:51 +00:00
|
|
|
.uiName = "PSI some CPU",
|
|
|
|
.caption = "PSI some CPU: ",
|
|
|
|
.description = "Pressure Stall Information, some cpu"
|
2020-08-20 03:59:41 +00:00
|
|
|
};
|
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
const MeterClass PressureStallIOSomeMeter_class = {
|
2020-08-20 03:59:41 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = PressureStallMeter_display,
|
|
|
|
},
|
|
|
|
.updateValues = PressureStallMeter_updateValues,
|
|
|
|
.defaultMode = TEXT_METERMODE,
|
|
|
|
.maxItems = 3,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = PressureStallMeter_attributes,
|
|
|
|
.name = "PressureStallIOSome",
|
2020-11-29 14:27:51 +00:00
|
|
|
.uiName = "PSI some IO",
|
|
|
|
.caption = "PSI some IO: ",
|
|
|
|
.description = "Pressure Stall Information, some io"
|
2020-08-20 03:59:41 +00:00
|
|
|
};
|
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
const MeterClass PressureStallIOFullMeter_class = {
|
2020-08-20 03:59:41 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = PressureStallMeter_display,
|
|
|
|
},
|
|
|
|
.updateValues = PressureStallMeter_updateValues,
|
|
|
|
.defaultMode = TEXT_METERMODE,
|
|
|
|
.maxItems = 3,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = PressureStallMeter_attributes,
|
|
|
|
.name = "PressureStallIOFull",
|
2020-11-29 14:27:51 +00:00
|
|
|
.uiName = "PSI full IO",
|
|
|
|
.caption = "PSI full IO: ",
|
|
|
|
.description = "Pressure Stall Information, full io"
|
2020-08-20 03:59:41 +00:00
|
|
|
};
|
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
const MeterClass PressureStallMemorySomeMeter_class = {
|
2020-08-20 03:59:41 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = PressureStallMeter_display,
|
|
|
|
},
|
|
|
|
.updateValues = PressureStallMeter_updateValues,
|
|
|
|
.defaultMode = TEXT_METERMODE,
|
|
|
|
.maxItems = 3,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = PressureStallMeter_attributes,
|
|
|
|
.name = "PressureStallMemorySome",
|
2020-11-29 14:27:51 +00:00
|
|
|
.uiName = "PSI some memory",
|
|
|
|
.caption = "PSI some memory: ",
|
|
|
|
.description = "Pressure Stall Information, some memory"
|
2020-08-20 03:59:41 +00:00
|
|
|
};
|
|
|
|
|
2020-10-13 12:35:30 +00:00
|
|
|
const MeterClass PressureStallMemoryFullMeter_class = {
|
2020-08-20 03:59:41 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete,
|
|
|
|
.display = PressureStallMeter_display,
|
|
|
|
},
|
|
|
|
.updateValues = PressureStallMeter_updateValues,
|
|
|
|
.defaultMode = TEXT_METERMODE,
|
|
|
|
.maxItems = 3,
|
|
|
|
.total = 100.0,
|
|
|
|
.attributes = PressureStallMeter_attributes,
|
|
|
|
.name = "PressureStallMemoryFull",
|
2020-11-29 14:27:51 +00:00
|
|
|
.uiName = "PSI full memory",
|
|
|
|
.caption = "PSI full memory: ",
|
|
|
|
.description = "Pressure Stall Information, full memory"
|
2020-08-20 03:59:41 +00:00
|
|
|
};
|