Xinqi Bao's Git
0cc1f880a7242b9ffea2cbe53bc71b19e09562af
11 return (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
13 bprintf("%d", (freq
+ 500) / 1000) : NULL
;
20 static long double a
[7];
24 memcpy(b
, a
, sizeof(b
));
25 if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a
[0], &a
[1], &a
[2],
26 &a
[3], &a
[4], &a
[5], &a
[6]) != 7) {
34 perc
= 100 * ((b
[0]+b
[1]+b
[2]+b
[5]+b
[6]) - (a
[0]+a
[1]+a
[2]+a
[5]+a
[6])) /
35 ((b
[0]+b
[1]+b
[2]+b
[3]+b
[4]+b
[5]+b
[6]) - (a
[0]+a
[1]+a
[2]+a
[3]+a
[4]+a
[5]+a
[6]));
37 return bprintf("%d", perc
);
45 static long double a
[7];
48 memcpy(b
, a
, sizeof(b
));
49 if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a
[0], &a
[1], &a
[2],
50 &a
[3], &a
[4], &a
[5], &a
[6]) != 7) {
58 perc
= 100 * ((b
[4]) - (a
[4])) /
59 ((b
[0]+b
[1]+b
[2]+b
[3]+b
[4]+b
[5]+b
[6]) - (a
[0]+a
[1]+a
[2]+a
[3]+a
[4]+a
[5]+a
[6]));
61 return bprintf("%d", perc
);