added instructions for benchmarking

This commit is contained in:
Tiziano Zito 2024-08-08 12:46:15 +02:00
parent 9b17d7b2d6
commit f8b83015fa

View file

@ -1,6 +1,23 @@
#!/usr/bin/python3
# Run it with
# export CPU=0; /usr/bin/taskset --cpu-list $CPU ./bench.py $CPU
# Commands and ideas from: https://llvm.org/docs/Benchmarking.html
# we assume that CPU 0 and 1 are together in an intel SMT-pair (hyperthreading)
# - Disable address space randomization:
# echo 0 > /proc/sys/kernel/randomize_va_space
# - Set scaling governor to performance for CPU 0
# echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# - Reserve CPU 0 fro our benchmark
# cset shield --cpu 0 --kthread=on
# - Disable the SMT-peer of CPU 0, i.e. CPU 1
# echo 0 > /sys/devices/system/cpu/cpu1/online
# - Disable turbo mode (works only on Intel):
# echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
# - Run with
# cset shield --exec -- ./bench.py
#
# To use the full power of the CPU, skip all the other steps and
# just run with
# taskset --cpu-list 0 ./bench.py
import os
import sys
import timeit