kubeless/benchmark/benchmark.sh

75 lines
2.2 KiB
Bash
Raw Normal View History

2019-04-02 22:18:13 +02:00
#!/bin/bash
2019-04-03 00:10:38 +02:00
functions=(hello)
2019-04-02 23:22:28 +02:00
connections=(2 5 10 20 50 100 200 400 500 1000)
2019-04-03 12:17:36 +02:00
times=(1m)
2019-04-03 00:10:38 +02:00
data=(isprime)
2019-04-02 22:46:20 +02:00
kuberhost="node1:32764"
2019-04-03 12:17:36 +02:00
maxthreads=160
2019-04-03 12:45:16 +02:00
wrk_options="-t$threads -d$time -c$connection -H\"Host: $function.kubeless\" -H\"Content-Type:application/json\" --latency http://$kuberhost/$function"
2019-04-03 12:39:30 +02:00
wrk_output=$function.$connection.$time.txt
2019-04-03 12:45:16 +02:00
hey_options="-c $connection -z $time -o csv -m POST -host \"$function.kubeless\" -T \"application/json\" http://$kuberhost/$function"
2019-04-03 12:39:30 +02:00
hey_output=$function.$connection.$time.csv
array_contains () {
local array="$1[@]"
local seeking=$2
local in=1
for element in "${!array}"; do
if [[ $element == $seeking ]]; then
in=0
break
fi
done
return $in
}
2019-04-02 23:42:11 +02:00
2019-04-02 23:01:26 +02:00
WRK_INSTALLED=$(which wrk)
2019-04-02 23:11:40 +02:00
if [ "$WRK_INSTALLED" = "" ]
2019-04-02 23:01:26 +02:00
then
2019-04-03 12:25:06 +02:00
apt update
apt install build-essential libssl-dev git -y
2019-04-02 23:04:16 +02:00
git clone https://github.com/wg/wrk.git wrk
cd wrk
make
2019-04-02 23:06:01 +02:00
cp wrk /usr/local/bin
2019-04-02 23:01:26 +02:00
fi
HEY_INSTALLED=$(which hey)
2019-04-02 23:11:40 +02:00
if [ "$HEY_INSTALLED" = "" ]
2019-04-02 23:01:26 +02:00
then
apt update
2019-04-02 23:04:16 +02:00
apt install -y golang
go get -u github.com/rakyll/hey
2019-04-02 23:08:21 +02:00
cp $HOME/go/bin/hey /usr/local/bin
2019-04-02 23:01:26 +02:00
fi
2019-04-02 22:18:13 +02:00
2019-04-03 00:27:58 +02:00
echo -e "Benchmarking GET functions\n"
2019-04-02 22:18:13 +02:00
for function in "${functions[@]}"
do
echo -e "Benchmarking $function\n"
2019-04-02 23:15:53 +02:00
echo -e "Output of $function is:\n"
2019-04-03 12:39:30 +02:00
array_contains data function && perl -pi -e 'chomp if eof' $function.body
2019-04-03 12:45:16 +02:00
curl_additional_options=$(array_contains data function && "--data-binary \"@$function.body\"")
2019-04-03 12:39:30 +02:00
curl $curl_additional_options --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/$function
2019-04-03 00:10:38 +02:00
echo -e "\n"
2019-04-03 12:39:30 +02:00
wrk_additional_options=$(array_contains data function && "-s$function.wrk")
hey_additional_options=$(array_contains data function && "-D $function.body")
2019-04-03 00:10:38 +02:00
for connection in "${connections[@]}"
do
2019-04-03 12:17:36 +02:00
if [[ $connection -lt $(($maxthreads + 1)) ]]
2019-04-03 00:10:38 +02:00
then
threads=$(($connection-1))
else
2019-04-03 12:17:36 +02:00
threads=$maxthreads
2019-04-03 00:10:38 +02:00
fi
echo -e "Threads: $threads Connections $connection\n"
for time in "${times[@]}"
do
echo -e "Time: $time\n"
2019-04-03 12:39:30 +02:00
wrk $wrk_options $wrk_additional_options > $wrk_output 2>&1
hey $hey_options $hey_additional_options > $hey_output
2019-04-03 00:10:38 +02:00
done
done
done