sanityy check

This commit is contained in:
2026-07-20 20:45:08 +02:00
parent 12135f0a33
commit 4ecce5c4d0

View File

@@ -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;