Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
6 #include "../../util.h"
13 return (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
15 bprintf("%d", (freq
+ 500) / 1000) : NULL
;
22 static long double a
[7];
26 memcpy(b
, a
, sizeof(b
));
27 if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a
[0], &a
[1], &a
[2],
28 &a
[3], &a
[4], &a
[5], &a
[6]) != 7) {
36 perc
= 100 * ((b
[0]+b
[1]+b
[2]+b
[5]+b
[6]) - (a
[0]+a
[1]+a
[2]+a
[5]+a
[6])) /
37 ((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]));
39 return bprintf("%d", perc
);
47 static long double a
[7];
50 memcpy(b
, a
, sizeof(b
));
51 if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a
[0], &a
[1], &a
[2],
52 &a
[3], &a
[4], &a
[5], &a
[6]) != 7) {
60 perc
= 100 * ((b
[4]) - (a
[4])) /
61 ((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]));
63 return bprintf("%d", perc
);