Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 108 lines (97 sloc) 3.934 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
#!/bin/bash

test_path="/mnt/data/bench" # location of files on physical disk
ramdisk="/scratch/bench" # where to do the test - select a ramdisk to min hdd usage
source="linux-3.6.9" # name of the dir containing the preconfigured linux source

limit="37" # number of times to run echo benchmark
PHYSICALCORES="4" # number of physical cores NOT counting hyperthreads ones
MAKEFLAGS="8" # number of make flags which should be one more than the physical+virtual cores
NAME=$(uname -r)

#####

do_make() {
BENCH=make
echo "Running Make..."
[[ ! -d $ramdisk/$source ]] ; tar xf $test_path/$source.tar -C $ramdisk
cd "$ramdisk/$source"
x=0
while [ "$x" -lt "$limit" ]; do
x=$(( $x + 1 ))
make clean &>/dev/null
RUNDATE=$(date "+%F %T")
start=$(date +%s.%N)
make -j$MAKEFLAGS bzImage &>/dev/null
end=$(date +%s.%N)
diff=$(echo "scale=6; $end - $start" | bc)
simpdiff=$(echo "scale=2; $end - $start" | bc)
runsleft=$(echo "scale=2; $limit-$x"| bc)
secleft=$(echo "scale=2; $runsleft*$diff"|bc)
minleft=$(echo "scale=2; $runsleft*$diff/60"|bc)
eta=$(date -d "($date) $secleft sec" +%r)
echo "Run $x/$limit took $simpdiff seconds. ETA: $eta or about $minleft min from now."
echo "$x,$RUNDATE,$HOSTNAME,$MAKEFLAGS,$NAME,$diff,$BENCH" >> $test_path/results.txt
done
cd $ramdisk && rm -rf $ramdisk/$source # cleanup
}

do_video() {
BENCH=video
echo "Running video..."
rsync -ax $test_path/2m-720p.mpg $ramdisk
cd $ramdisk
x=0
while [ "$x" -lt "$limit" ]; do
x=$(( $x + 1 ))
RUNDATE=$(date "+%F %T")
start=$(date +%s.%N)
#360p video for iphones
ffmpeg -i 2m-720p.mpg -vcodec libx264 -vprofile baseline -preset slow -b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -threads 0 -acodec copy out.mp4
end=$(date +%s.%N)
diff=$(echo "scale=6; $end - $start" | bc)
simpdiff=$(echo "scale=2; $end - $start" | bc)
runsleft=$(echo "scale=2; $limit-$x"| bc)
secleft=$(echo "scale=2; $runsleft*$diff"|bc)
minleft=$(echo "scale=2; $runsleft*$diff/60"|bc)
eta=$(date -d "($date) $secleft sec" +%r)
echo "Run $x/$limit took $simpdiff seconds. ETA: $eta or about $minleft min from now."
echo "$x,$RUNDATE,$HOSTNAME,$PHYSICALCORES,$NAME,$diff,$BENCH" >> "$test_path"/results.txt
rm -f out.mp4
done
rm -f $ramdisk/2m-720p.mpg # cleanup
}

do_compress() {
BENCH=compress
echo "Running compress..."
[[ ! -f $ramdisk/$source.tar ]] ; cp $test_path/$source.tar $ramdisk
cd "$ramdisk"
x=0
while [ "$x" -lt "$limit" ]; do
x=$(( $x + 1 ))
RUNDATE=$(date "+%F %T")
start=$(date +%s.%N)
lrzip $source.tar
end=$(date +%s.%N)
diff=$(echo "scale=6; $end - $start" | bc)
simpdiff=$(echo "scale=2; $end - $start" | bc)
runsleft=$(echo "scale=2; $limit-$x"| bc)
secleft=$(echo "scale=2; $runsleft*$diff"|bc)
minleft=$(echo "scale=2; $runsleft*$diff/60"|bc)
eta=$(date -d "($date) $secleft sec" +%r)
echo "Run $x/$limit took $simpdiff seconds. ETA: $eta or about $minleft min from now."
echo "$x,$RUNDATE,$HOSTNAME,$PHYSICALCORES,$NAME,$diff,$BENCH" >> $test_path/results.txt
rm -f $ramdisk/$source.tar.lrz
done
rm -f $ramdisk/$source.tar # cleanup
}

XSRUNNING=$(pidof xscreensaver)
[[ -n "$XSRUNNING" ]] && kill "$XSRUNNING"

[[ -z $(which bc) ]] && echo "Install bc to allow calculations." && exit 0
[[ -z $(which ffmpeg) ]] && echo "Install ffmpeg to allow for video benchmark." && exit 0
[[ -z $(which lrzip) ]] && echo "Install lrzip to allow for compression benchmark." && exit 0
[[ -z $(which gcc) ]] && echo "Install base-devel group to allow for make benchmark." && exit 0

[[ ! -d $ramdisk ]] && mkdir -p $ramdisk
[[ ! -f $test_path/results.txt ]] && echo "run #,run date,hostname,physical cores/threads,kernel,time(sec),benchmark" > $test_path/results.txt

case "$1" in
compress) do_compress ;;
video) do_video ;;
make) do_make ;;
all) do_compress ; do_make ; do_video ;;
*) echo "Usage: $0 {pics|video|make|compress|all}" ; exit 0 ;;
esac
Something went wrong with that request. Please try again.