#!/bin/sh ##modifiable variables #high-level parameters runtime=3600 corelist=-1 interval=200 full_test=0 do_stress=1 mode="svg" out_dir=$(pwd) #stress parameters c_hogs=2 v_hogs=2 v_mem="128M" d_hogs=1 i_hogs=2 #constants start_dir=$(pwd) work_dir="/tmp/tuned" hist_max=400 #handle optional arguments #end option handling c_str="" v_str="" d_str="" i_str="" if [ $c_hogs -gt 0 ]; then c_str="-c $c_hogs" fi if [ $v_hogs -gt 0 ]; then v_str="--vm $v_hogs --vm-bytes $v_mem" fi if [ $d_hogs -gt 0 ]; then d_str="-d $d_hogs" fi if [ $i_hogs -gt 0 ]; then i_str="-i $i_hogs" fi n_intervals=$(($runtime*1000000/$interval)) mkdir -p $work_dir && cd $work_dir if [ $do_stress = 1 ]; then stress $c_str $v_str $d_str $i_str -t $((runtime+1)) & fi sudo cyclictest -m -t -a2-3 -c1 -p98 -i$interval -h$hist_max -l$n_intervals --mainaffinity=0 -q >output max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//` grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram ncores=2 fn="plot."$mode for j in `seq 1 $ncores` do column=`expr $j + 1` cut -f1,$column histogram >histogram$j done echo -n -e "set title \"Latency plot\"\n\ set terminal $mode\n\ set xlabel \"Latency (us), max $max us\"\n\ set logscale y\n\ set xrange [0:$hist_max]\n\ set yrange [0.8:*]\n\ set ylabel \"Number of latency samples\"\n\ set output \"$fn\"\n\ plot " >plotcmd for j in `seq 1 $ncores` do if test $j != 1 then echo -n ", " >>plotcmd fi cpuno=`expr $j - 1` if test $cpuno -lt 10 then title=" CPU$cpuno" else title="CPU$cpuno" fi echo -n "\"histogram$j\" using 1:2 title \"$title\" with histeps" >>plotcmd done gnuplot -persist