From 3c6430d7b2a15133e467a3a4e04a3a8a012d09f3 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 14 Nov 2010 18:52:44 -0300 Subject: [PATCH] Add a helper script to improve accuracy when benchmarking This script put the CPU in 'performance' mode to avoid distortion in the results because of CPU frequency changes. It also gives the process maximum CPU time and I/O priority using nice and ionice respectively. Finally, it only uses the number of CPUs specifiend in the CPUS environment variable to run the program. The scripts is used like this: CPUS=2 ./bench.sh some_prog --some-args This runs "some_prog" passing "--some-args" as arguments, using 2 CPUs. --- bench.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 bench.sh diff --git a/bench.sh b/bench.sh new file mode 100755 index 0000000..81b819b --- /dev/null +++ b/bench.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +export CPUS="$1" +shift + +cpu_list=`seq 0 $(($CPUS-1))` + +bye() { + for n in $cpu_list + do + cpufreq-set -c $n -g ondemand + done +} + +trap bye EXIT +trap bye INT + +for n in $cpu_list +do + cpufreq-set -c $n -g performance +done + +nice -n-19 ionice -c 1 taskset -c `echo $cpu_list | tr ' ' ,` "$@" + -- 2.43.0