-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbenchmark.sh
executable file
·97 lines (91 loc) · 2.13 KB
/
benchmark.sh
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
#!/bin/bash
RESULT=result
DOCKER_MICRO_BENCHMARK=./docker_micro_benchmark
STAT_TOOL=pidstat
GNUPLOT=gnuplot
PLOTDIR=plot
AWK=awk
usage () {
echo "Usage : `basename $0` -[o|c|i|r]"
exit
}
# $1 parameter, $2 benchmark name
doBenchmark() {
RDIR=$RESULT/$2
if [ ! -d $RDIR ]; then
mkdir $RDIR
fi
LC_ALL=C sar -rubwS -P ALL 1 > $RDIR/sar_benchmark.dat &
SAR_PID=$!
$DOCKER_MICRO_BENCHMARK $1 > $RDIR/result_benchmark.dat &
BENCHMARK_PID=$!
$STAT_TOOL -p $BENCHMARK_PID 1 > $RDIR/cpu_benchmark.dat &
DOCKER_PID=`ps -ef | awk '$8=="/usr/bin/docker" {print $2}'`
$STAT_TOOL -p $DOCKER_PID 1 > $RDIR/cpu_docker_daemon.dat &
DOCKER_PIDSTAT=$!
wait $BENCHMARK_PID
kill $SAR_PID
kill $DOCKER_PIDSTAT
kill $SAR_PID
doParse $2
}
# $1 benchmark name
doParse() {
RDIR=$RESULT/$1
DATA=result_benchmark.dat
TMP=tmp
TYPE=png
cd $RDIR
if [ -d $TMP ]; then
rm -r $TMP
fi
mkdir $TMP
$AWK '/^$/{getline file; "'${TMP}'/"file < /dev/null ; next} !/^$/{print >> "'${TMP}'/"file}' < $DATA
for file in `ls $TMP`; do
$GNUPLOT -e "ifilename='${TMP}/$file'; ofilename='latency-$file.$TYPE'" ../../$PLOTDIR/latency_plot
$GNUPLOT -e "ifilename='${TMP}/$file'; ofilename='$file.$TYPE'" ../../$PLOTDIR/$1/result_plot
done
$GNUPLOT ../../$PLOTDIR/cpu_plot
rm -r $TMP
cd - > /dev/null
}
if [ -z $1 ]; then
usage
exit 1
fi
if [ ! -d $RESULT ]; then
mkdir $RESULT
fi
while [ "$1" != "" ]; do
case $1 in
-o )
echo "Benchmark container operations"
doBenchmark $1 container_op
shift
;;
-c )
CONTAINER_NUMBER=`docker ps -a | wc -l`
CONTAINER_NUMBER=`expr $CONTAINER_NUMBER - 1`
if [ $CONTAINER_NUMBER -ne 0 ]; then
shell/kill_all_dockers.sh > /dev/null
fi
echo "Benchmark with different container numbers"
doBenchmark $1 varies_containers
shift
;;
-i )
echo "Benchmark with different intervals"
doBenchmark $1 varies_intervals
shift
;;
-r )
echo "Benchmark with different routine numbers"
doBenchmark $1 varies_routines
shift
;;
* )
usage
exit 1
;;
esac
done