RAPL
This commit is contained in:
parent
c9dc2a306e
commit
b3f7476b82
4 changed files with 152 additions and 25 deletions
24
powercap.c
Normal file
24
powercap.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue