From 4ecce5c4d09077bd4d41cb1133f181b5fe2eaa8d Mon Sep 17 00:00:00 2001 From: Drath Date: Mon, 20 Jul 2026 20:45:08 +0200 Subject: [PATCH] sanityy check --- src/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpu.c b/src/cpu.c index 33c0231..514abbe 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -37,11 +37,11 @@ void cpu_update(struct cpu_sensors_t *c) { clock_gettime(CLOCK_MONOTONIC, &curr.ts); fast_read_num_u64("/sys/class/powercap/intel-rapl:0/", "energy_uj", buf, &curr.energy, 1); - const uint64_t tdiff_us = timespec_diff_us(&curr.ts, &prev.ts); - c->ptotal = (float)(curr.energy - prev.energy) / (float)tdiff_us; - prev = curr; + c->ptotal = (float)(curr.energy - prev.energy) / (float)timespec_diff_us(&curr.ts, &prev.ts); if (c->ptotal > 500.0f || c->ptotal < 0.0f) c->ptotal = 0.0f; + else + prev = curr; // lots of reads but still faster than reading /proc/cpuinfo c->avg_freq = 0;