From 25cb42f0e4be70f02dc094d81e033ba21ec18b27 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 26 Aug 2023 16:56:06 +0800 Subject: Rework ZramMeter and remove MeterClass.comprisedValues The 'comprisedValues' boolean property unnecessarily complicates the drawing algorithms of Bar meters and Graph meters. Since the only user of 'comprisedValues' is ZramMeter, it is better to rework the meter so that it no longer needs 'comprisedValues'. The 'values[ZRAM_METER_UNCOMPRESSED]' now stores the difference between uncompressed and compressed data size. Signed-off-by: Kang-Che Sung --- pcp/Platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pcp') diff --git a/pcp/Platform.c b/pcp/Platform.c index 13746fc2..87a2ec1f 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -593,9 +593,13 @@ void Platform_setZramValues(Meter* this) { free(values); + if (stats.usedZramComp > stats.usedZramOrig) { + stats.usedZramComp = stats.usedZramOrig; + } + this->total = stats.totalZram; this->values[0] = stats.usedZramComp; - this->values[1] = stats.usedZramOrig; + this->values[1] = stats.usedZramOrig - stats.usedZramComp; } void Platform_setZfsArcValues(Meter* this) { -- cgit v1.2.3