#!/bin/bash

rm out.txt
echo "Start test" >> out.txt
aptitude -y install mc atop screen pbzip2 sysbench

CPU=$(cat /proc/cpuinfo  | grep -c processor)
((CPU--))

for i in `seq 0 $CPU`;
 do
  echo "performance" > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
 done


echo "HDD TEST DD line write" >> out.txt
echo 3 > /proc/sys/vm/drop_caches
dd if=/dev/zero of=/root/zerofile.tst bs=1M count=51200 2>> out.txt

echo "HDD TEST DD line read" >> out.txt
echo 3 > /proc/sys/vm/drop_caches
dd if=/root/zerofile.tst of=/dev/null bs=1M count=51200 2>> out.txt

rm /root/zerofile.tst

sysbench --num-threads=16 --test=fileio --file-total-size=50G --file-test-mode=rndrw prepare
echo "HDD TEST sysbench random read" >> out.txt
echo 3 > /proc/sys/vm/drop_caches
sysbench --num-threads=16 --test=fileio --file-total-size=50G --file-test-mode=rndrd --init-rng=on --max-time=300 --max-requests=0 run >> out.txt
#echo "HDD TEST sysbench random read 16Mb" >> out.txt
#echo 3 > /proc/sys/vm/drop_caches
#sysbench --num-threads=32 --test=fileio --file-total-size=50G --file-test-mode=rndrd --init-rng=on --max-time=300 --max-requests=0 --file-block-size=16M run  >> out.txt
echo "HDD TEST sysbench random write" >> out.txt
echo 3 > /proc/sys/vm/drop_caches
sysbench --num-threads=16 --test=fileio --file-total-size=50G --file-test-mode=rndwr --init-rng=on --max-time=300 --max-requests=0 run >> out.txt
echo "HDD TEST sysbench random read/write" >> out.txt
echo 3 > /proc/sys/vm/drop_caches
sysbench --num-threads=16 --test=fileio --file-total-size=50G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run >> out.txt
echo 3 > /proc/sys/vm/drop_caches
sysbench --num-threads=16 --test=fileio --file-total-size=50G --file-test-mode=rndrw cleanup
