24 lines
557 B
C
24 lines
557 B
C
// gcc -O3 powercap.c -o powercap
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
void read_energy(char *path) {
|
|
FILE *fd = fopen(path, "r");
|
|
if(fd) {
|
|
char buf[32];
|
|
int len = fread(buf, 1, 31, fd);
|
|
fclose(fd);
|
|
buf[len] = 0;
|
|
printf("%s", buf);
|
|
} else {
|
|
printf("-1\n");
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
read_energy("/sys/class/powercap/intel-rapl/subsystem/intel-rapl:0:0/energy_uj");
|
|
read_energy("/sys/class/powercap/intel-rapl/subsystem/intel-rapl:0:1/energy_uj");
|
|
read_energy("/sys/class/powercap/intel-rapl/subsystem/intel-rapl:0:2/energy_uj");
|
|
return 0;
|
|
}
|