summaryrefslogtreecommitdiff
path: root/components/cpu.c
diff options
context:
space:
mode:
authorivan-boikov <ik.boikov.public@protonmail.com>2024-12-22 16:39:10 +0100
committerivan-boikov <ik.boikov.public@protonmail.com>2024-12-22 16:39:10 +0100
commit3e2132d9a57962d2a60676568059bac76ea73275 (patch)
treeab524bed9a3758eb1972801489859a71684a74af /components/cpu.c
parente4b38bac467d969e92a0e9609ea6f5761ce1b66e (diff)
Configuring CPU count
Diffstat (limited to 'components/cpu.c')
-rw-r--r--components/cpu.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/components/cpu.c b/components/cpu.c
index a78f17a..48e1b60 100644
--- a/components/cpu.c
+++ b/components/cpu.c
@@ -6,23 +6,23 @@
#include "../slstatus.h"
#include "../util.h"
+#define CPUS 12
+
#if defined(__linux__)
const char *
cpu_freq(const char *unused)
{
- char cpu[128];
unsigned int cores = 0;
uintmax_t freq, freq_sum = 0;
- while (1) {
- sprintf(cpu, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", cores);
- if (pscanf(cpu, "%ju", &freq) != 1)
+ for (; cores < CPUS; ++cores) {
+ sprintf(buf, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", cores);
+ if (pscanf(buf, "%ju", &freq) != 1)
break;
freq_sum += freq;
- cores++;
}
- return bprintf("%.1f", freq_sum/1e6/cores);
+ return bprintf("%.1f", freq_sum/1e6/CPUS);
}
const char *