From 33f343fa0a8a66911a6e40a73a464af1f2c4508a Mon Sep 17 00:00:00 2001 From: Drath Date: Wed, 29 Oct 2025 01:19:17 +0100 Subject: [PATCH] we only read power from rapl now --- src/cpu.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/cpu.cpp b/src/cpu.cpp index 09e2c59..7dc6af1 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -26,23 +26,21 @@ void update(cpuSensors* c) { // cpu.tdie = std::stoi(readFile(hw.path + "/temp1_input", 2)); c->tctl = std::stoi(readFile(c->hwmon + "/temp2_input", 2)); c->tccd1 = std::stoi(readFile(c->hwmon + "/temp3_input", 2)); - c->pcore = (double)(std::stoi(readFile(c->hwmon + "/power1_input", 3)) / 100.0); - c->psoc = (double)(std::stoi(readFile(c->hwmon + "/power2_input", 3)) / 100.0); - c->ptotal = c->pcore + c->psoc; c->vcore = (double)(std::stoul(readFile(c->hwmon + "/in1_input", 4)) / 1000.0); // cpu.vsoc = (double)(std::stoul(readFile(hw.path + "/in2_input")) / 1000.0); } else { c->tctl = std::stoi(readFile(c->hwmon + "/temp1_input", 2)); c->tccd1 = std::stoi(readFile(c->hwmon + "/temp3_input", 2)); - // read power from intel-rapl? works on amd too, btop uses this trick, seems accurate - // it tracks with "socket power" in hwinfo on windows, its actually the same thing i had in lcdsmartie - auto current_ts = std::chrono::steady_clock::now(); - auto current_usage = std::stoul(readFile("/sys/class/powercap/intel-rapl:0/energy_uj", 24)); - c->ptotal = (float)(current_usage - previous_usage) / (float)(std::chrono::duration_cast(current_ts - previous_ts).count()); - previous_ts = current_ts; - previous_usage = current_usage; } + // read power from intel-rapl? works on amd too, btop uses this trick, seems accurate + // it tracks with "socket power" in hwinfo on windows, its actually the same thing i had in lcdsmartie + auto current_ts = std::chrono::steady_clock::now(); + auto current_usage = std::stoul(readFile("/sys/class/powercap/intel-rapl:0/energy_uj", 24)); + c->ptotal = (float)(current_usage - previous_usage) / (float)(std::chrono::duration_cast(current_ts - previous_ts).count()); + previous_ts = current_ts; + previous_usage = current_usage; + // lots of reads but still faster than reading /proc/cpuinfo char buf[8]; c->avg_freq = 0;