we only read power from rapl now
This commit is contained in:
18
src/cpu.cpp
18
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<std::chrono::microseconds>(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<std::chrono::microseconds>(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;
|
||||
|
||||
Reference in New Issue
Block a user