Skip to content

Instantly share code, notes, and snippets.

@MrCroxx
Created August 22, 2024 05:59
Show Gist options
  • Select an option

  • Save MrCroxx/10d5d0e96ef74743f9e8afe292b31025 to your computer and use it in GitHub Desktop.

Select an option

Save MrCroxx/10d5d0e96ef74743f9e8afe292b31025 to your computer and use it in GitHub Desktop.
> ~/github/tsuna/contextswitch make all  ✔  mrcroxx@homelab  05:55:12 
gcc -pthread -march=native -O3 -mno-avx -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -std=c99 -W -Wall -Werror -lrt -lpthread timectxsw.c -o timectxsw
gcc -pthread -march=native -O3 -mno-avx -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -std=c99 -W -Wall -Werror -lrt -lpthread timectxswws.c -o timectxswws
gcc -pthread -march=native -O3 -mno-avx -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -std=c99 -W -Wall -Werror -lrt -lpthread timesyscall.c -o timesyscall
gcc -pthread -march=native -O3 -mno-avx -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -std=c99 -W -Wall -Werror -lrt -lpthread timetctxsw.c -o timetctxsw
gcc -pthread -march=native -O3 -mno-avx -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -std=c99 -W -Wall -Werror -lrt -lpthread timetctxsw2.c -o timetctxsw2
./cpubench.sh
model name : AMD Ryzen 9 7950X 16-Core Processor
1 physical CPUs, 16 cores/CPU, 2 hardware threads/core = 32 hw threads total
-- No CPU affinity --
10000000 system calls in 1017933137ns (101.8ns/syscall)
2000000 process context switches in 4232319466ns (2116.2ns/ctxsw)
2000000 thread context switches in 4425227681ns (2212.6ns/ctxsw)
sched_setscheduler(): Operation not permitted
2000000 thread context switches in 172368054ns (86.2ns/ctxsw)
-- With CPU affinity --
10000000 system calls in 975160980ns (97.5ns/syscall)
2000000 process context switches in 5335977552ns (2668.0ns/ctxsw)
2000000 thread context switches in 5004306873ns (2502.2ns/ctxsw)
sched_setscheduler(): Operation not permitted
2000000 thread context switches in 995713966ns (497.9ns/ctxsw)
-- With CPU affinity to CPU 0 --
10000000 system calls in 974760363ns (97.5ns/syscall)
2000000 process context switches in 4164152540ns (2082.1ns/ctxsw)
2000000 thread context switches in 4319097459ns (2159.5ns/ctxsw)
sched_setscheduler(): Operation not permitted
2000000 thread context switches in 172233551ns (86.1ns/ctxsw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment