From 874d720e9c9ff13d8870389d9d81dcd424572b98 Mon Sep 17 00:00:00 2001 From: Laurent MAZET Date: Thu, 16 Oct 2025 19:31:48 +0200 Subject: [PATCH] get cpu clock --- getinfo.sh | 2 +- load.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/getinfo.sh b/getinfo.sh index 6886ac8..520c156 100755 --- a/getinfo.sh +++ b/getinfo.sh @@ -4,7 +4,7 @@ echo OS: $(uname -a 2>/dev/null || cat /proc/version) echo "Model: $(cat /proc/cpuinfo | awk -F: '/[mM]odel/ {print $2; exit}')" cat /proc/cpuinfo | awk '/Features/ { sub(/\t/, ""); print; exit }' echo Nb cores: $(grep -c processor /proc/cpuinfo) -echo Core frequency: unknown +./load -c cat /proc/meminfo | awk '/MemTotal/ { printf "Memory: %dGB\n", ($2+2^20-1)/2^20 }' echo Mem frequency: unknown diff --git a/load.c b/load.c index 6a10751..b1062f1 100644 --- a/load.c +++ b/load.c @@ -2,6 +2,7 @@ /* cflags: */ /* linker: mtime.o -lpthread */ +#define _GNU_SOURCE #include //#include #include @@ -297,6 +298,13 @@ int main (int argc, char *argv[]) /* main process */ if (mode) { + cpu_set_t cpu_mask; + CPU_ZERO (&cpu_mask); + CPU_SET (0, &cpu_mask); + if (pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpu_mask) != 0) { + fprintf (stderr, "error: pthread_setaffinity_np\n"); + return 1; + } while (mode--) { printf ("\r"); printf ("Tics clock: %.0fMHz", estimate_tics_clock () / 1e6); -- 2.30.2