Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
12 return (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
14 bprintf("%d", (freq
+ 500) / 1000) : NULL
;
21 static long double a
[7];
25 memcpy(b
, a
, sizeof(b
));
26 if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a
[0], &a
[1], &a
[2],
27 &a
[3], &a
[4], &a
[5], &a
[6]) != 7) {
35 perc
= 100 * ((b
[0]+b
[1]+b
[2]+b
[5]+b
[6]) - (a
[0]+a
[1]+a
[2]+a
[5]+a
[6])) /
36 ((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]));
38 return bprintf("%d", perc
);
46 static long double a
[7];
49 memcpy(b
, a
, sizeof(b
));
50 if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a
[0], &a
[1], &a
[2],
51 &a
[3], &a
[4], &a
[5], &a
[6]) != 7) {
59 perc
= 100 * ((b
[4]) - (a
[4])) /
60 ((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]));
62 return bprintf("%d", perc
);