2019-04-02 22:18:13 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-04-25 13:46:53 +02:00
|
|
|
functions=(isprime-scale)
|
2019-04-17 15:26:03 +02:00
|
|
|
connections=(50)
|
2019-04-25 11:21:38 +02:00
|
|
|
times=(1m)
|
2019-04-25 10:51:04 +02:00
|
|
|
kuberhost="node1:30765"
|
2019-04-17 14:09:03 +02:00
|
|
|
maxthreads=40
|
2019-04-02 23:42:11 +02:00
|
|
|
|
2019-04-26 14:45:14 +02:00
|
|
|
wave_function=isprime
|
2019-04-26 14:32:55 +02:00
|
|
|
wave_dir_up=true
|
|
|
|
wave_connection=40
|
|
|
|
wave_max_conn=1600
|
|
|
|
wave_min_conn=40
|
2019-04-25 13:46:53 +02:00
|
|
|
wave_time="1m"
|
|
|
|
|
2019-04-26 14:32:55 +02:00
|
|
|
WRK_INSTALLED=$(command -v wrk)
|
2019-04-25 13:46:53 +02:00
|
|
|
if [[ $WRK_INSTALLED = "" ]]
|
2019-04-02 23:01:26 +02:00
|
|
|
then
|
2019-04-17 14:09:03 +02:00
|
|
|
apt update
|
|
|
|
apt install build-essential libssl-dev git -y
|
|
|
|
git clone https://github.com/wg/wrk.git wrk
|
2019-04-26 14:32:55 +02:00
|
|
|
cd wrk || exit
|
2019-04-17 14:09:03 +02:00
|
|
|
make
|
|
|
|
cp wrk /usr/local/bin
|
2019-04-02 23:01:26 +02:00
|
|
|
fi
|
|
|
|
|
2019-04-26 14:32:55 +02:00
|
|
|
HEY_INSTALLED=$(command -v hey)
|
2019-04-25 13:46:53 +02:00
|
|
|
if [[ $HEY_INSTALLED = "" ]]
|
2019-04-02 23:01:26 +02:00
|
|
|
then
|
2019-04-17 14:09:03 +02:00
|
|
|
apt update
|
|
|
|
apt install -y golang
|
|
|
|
go get -u github.com/rakyll/hey
|
2019-04-26 14:32:55 +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-26 14:40:40 +02:00
|
|
|
if [[ $* = *"--wave"* ]]
|
2019-04-25 13:46:53 +02:00
|
|
|
then
|
|
|
|
while true; do
|
|
|
|
now=$(date '+%Y-%m-%d-%H-%M')
|
|
|
|
echo -e "Running"
|
2019-04-26 14:45:14 +02:00
|
|
|
hey -c $wave_connection -z $wave_time -m POST -o csv -host "$wave_function.kubeless" -D "$wave_function".body -T "application/json" http://$kuberhost/"$wave_function" > ./"$wave_function"."$now".wave.txt
|
2019-04-25 13:46:53 +02:00
|
|
|
echo -e "Sleeping"
|
2019-04-26 14:45:14 +02:00
|
|
|
sleep $wave_time
|
2019-04-26 14:32:55 +02:00
|
|
|
if [[ $wave_dir_up ]]
|
|
|
|
then
|
|
|
|
if [[ $wave_connection -lt $wave_max_conn ]]
|
|
|
|
then
|
|
|
|
wave_connection=$((wave_connection * 2))
|
|
|
|
else
|
|
|
|
wave_dir_up=false
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [[ $wave_connection -gt $wave_min_conn ]]
|
|
|
|
then
|
|
|
|
wave_connection=$((wave_connection / 2))
|
|
|
|
else
|
|
|
|
wave_dir_up=true
|
|
|
|
fi
|
|
|
|
fi
|
2019-04-25 13:46:53 +02:00
|
|
|
done
|
|
|
|
else
|
2019-04-17 15:26:03 +02:00
|
|
|
echo -e "Benchmarking 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-26 14:32:55 +02:00
|
|
|
perl -pi -e 'chomp if eof' "$function".body
|
|
|
|
curl --data-binary @"$function".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
|
2019-04-03 00:10:38 +02:00
|
|
|
echo -e "\n"
|
|
|
|
for connection in "${connections[@]}"
|
|
|
|
do
|
2019-04-26 14:32:55 +02:00
|
|
|
if [[ $connection -lt $((maxthreads + 1)) ]]
|
2019-04-03 00:10:38 +02:00
|
|
|
then
|
2019-04-26 14:32:55 +02:00
|
|
|
threads=$((connection-1))
|
2019-04-03 00:10:38 +02:00
|
|
|
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"
|
2019-04-17 14:09:03 +02:00
|
|
|
for time in "${times[@]}"
|
|
|
|
do
|
2019-04-17 15:26:03 +02:00
|
|
|
datetime=$(date '+%Y-%m-%d-%H-%M-%S')
|
2019-04-25 13:46:53 +02:00
|
|
|
echo -e "Time: $time\n"
|
|
|
|
echo -e "wrk\n"
|
2019-04-26 14:32:55 +02:00
|
|
|
wrk -t$threads -c"$connection" -d"$time" -s"$function".wrk -H"Host: $function.kubeless" -H"Content-Type:application/json" --latency http://$kuberhost/"$function" > ./"$function"."$connection"."$time"."$datetime".wrk.txt 2>&1
|
2019-04-25 13:46:53 +02:00
|
|
|
echo -e "hey-summary\n"
|
2019-04-26 14:32:55 +02:00
|
|
|
hey -c "$connection" -z "$time" -m POST -host "$function.kubeless" -D "$function".body -T "application/json" http://$kuberhost/"$function" > ./"$function"."$connection"."$time"."$datetime".hey.txt
|
2019-04-25 13:46:53 +02:00
|
|
|
echo -e "hey-csv\n"
|
2019-04-26 14:32:55 +02:00
|
|
|
hey -c "$connection" -z "$time" -m POST -o csv -host "$function.kubeless" -D "$function".body -T "application/json" http://$kuberhost/"$function" > ./"$function"."$connection"."$time"."$datetime".csv
|
|
|
|
echo -e "$datetime"
|
2019-04-03 00:10:38 +02:00
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
2019-04-25 13:46:53 +02:00
|
|
|
fi
|