knative-report/benchmark/classic/benchmark.sh

149 lines
6.3 KiB
Bash
Raw Normal View History

2019-10-02 18:27:25 +02:00
#!/usr/bin/env bash
#Requirements:
#<function name without dashes>.wrk descriptor file for wrk
#<function name without dashes>.body (even if you don't need it)
#Configuration variables
2019-10-14 21:25:37 +02:00
functions=(isprime-kubeless-go-sc)
2019-10-20 21:53:43 +02:00
connections=(45)
times=(30s)
2019-10-14 21:25:37 +02:00
kuberhost="node1:31299"
2019-10-02 18:27:25 +02:00
maxthreads=40
#Wave mode configuration
wave_connection=40
wave_max_conn=160
wave_min_conn=40
2019-10-20 21:53:43 +02:00
wave_time="30s"
2019-10-02 18:27:25 +02:00
wave_loop_max=2
2019-10-20 21:53:43 +02:00
#Climb mode configuration
climb_max=300
climb_connection=30
2019-10-20 22:20:05 +02:00
kubeless=true
2019-10-02 18:27:25 +02:00
HEY_INSTALLED=$(command -v hey)
if [[ $HEY_INSTALLED = "" ]]
then
apt update
apt install -y golang
go get -u github.com/rakyll/hey
cp "$HOME"/go/bin/hey /usr/local/bin
fi
echo -e "Benchmarking functions\n"
for function in "${functions[@]}"
do
function_friendly=$(echo $function | cut - -d'-' -f1)
echo -e "Benchmarking $function\n"
echo -e "Output of $function is:\n"
perl -pi -e 'chomp if eof' "$function_friendly".body
2019-10-20 22:41:00 +02:00
if $kubeless;
2019-10-20 22:20:05 +02:00
then
curl --data-binary @"$function_friendly".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
else
curl --header "Host: $function.default.example.com" http://$kuberhost/
fi
2019-10-02 18:27:25 +02:00
echo -e "\n"
if [[ $* = *"--wave"* ]]
then
wave_loop=1
wave_dir_up=true
2019-10-18 23:10:48 +02:00
wave_num=1
2019-10-02 18:27:25 +02:00
while [[ $wave_loop -lt $wave_loop_max ]]; do
now=$(date '+%Y-%m-%d-%H-%M')
echo -e "Connections: $wave_connection"
echo -e "Running"
2019-10-20 22:41:00 +02:00
if $kubeless;
2019-10-20 22:20:05 +02:00
then
hey -c $wave_connection -z $wave_time -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$wave_num".wave.csv
else
hey -c $wave_connection -z $wave_time -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$wave_num".wave.csv
fi
2019-10-18 23:10:48 +02:00
wave_num=$((wave_num + 1))
2019-10-02 18:27:25 +02:00
if $wave_dir_up
then
if [[ $wave_connection -lt $wave_max_conn ]]
then
echo -e "Stepping up"
wave_connection=$((wave_connection * 5))
else
echo -e "Not stepping"
wave_dir_up=false
fi
else
if [[ $wave_connection -gt $wave_min_conn ]]
then
echo -e "Stepping down"
wave_connection=$((wave_connection / 5))
else
echo -e "Not stepping"
wave_dir_up=true
wave_loop=$((wave_loop + 1))
fi
fi
done
else
for connection in "${connections[@]}"
do
if [[ $connection -lt $((maxthreads + 1)) ]]
then
threads=$((connection-1))
else
threads=$maxthreads
fi
echo -e "Threads: $threads Connections $connection\n"
for time in "${times[@]}"
2019-10-20 23:49:19 +02:00
do
2019-10-02 18:27:25 +02:00
datetime=$(date '+%Y-%m-%d-%H-%M-%S')
echo -e "Time: $time\n"
if [[ $* = *"--hey"* ]]
then
echo -e "hey-summary $datetime\n"
2019-10-20 22:41:00 +02:00
if $kubeless;
2019-10-20 22:20:05 +02:00
then
hey -c "$connection" -z "$time" -m POST -host "$function.kubeless" -D "$function_firendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$connection"."$time"."$datetime".hey.txt
else
hey -c "$connection" -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$connection"."$time"."$datetime".hey.txt
fi
2019-10-02 18:27:25 +02:00
fi
if [[ $* = *"--csv"* ]]
then
echo -e "hey-csv $datetime\n"
2019-10-20 22:41:00 +02:00
if $kubeless;
2019-10-20 22:20:05 +02:00
then
hey -c "$connection" -z "$time" -m POST -host "$function.kubeless" -D "$function_firendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$connection"."$time"."$datetime".hey.txt
else
hey -c "$connection" -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$connection"."$time"."$datetime".hey.txt
fi
2019-10-02 18:27:25 +02:00
fi
2019-10-20 21:33:49 +02:00
if [[ $* = *"--for"* ]]
2019-10-20 22:20:05 +02:00
then
2019-10-20 21:33:49 +02:00
for num in 1 2 3 4 5 6 7 8 9 10
do
2019-10-20 22:20:05 +02:00
echo -e "hey-for $num\n"
2019-10-20 22:41:00 +02:00
if $kubeless;
then
hey -c "$connection" -z "$time" -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$num".csv
else
hey -c "$connection" -z "$time" -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$num".csv
fi
2019-10-20 21:33:49 +02:00
done
fi
2019-10-02 18:27:25 +02:00
done
done
fi
2019-10-20 21:53:43 +02:00
if [[ $* = *"--climb"* ]]
2019-10-20 22:20:05 +02:00
then
2019-10-20 21:53:43 +02:00
while [[ $climb_connection -lt $climb_max ]]; do
2019-10-20 23:49:19 +02:00
echo -e "Connections: $climb_connection"
2019-10-20 22:41:00 +02:00
if $kubeless;
2019-10-20 22:20:05 +02:00
then
hey -c $climb_connection -z $time -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$climb_connection".wave.csv
else
hey -c $climb_connection -z $time -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$climb_connection".wave.csv
fi
2019-10-20 21:53:43 +02:00
climb_connection=$((climb_connection + 10))
done
fi
2019-10-20 23:49:19 +02:00
echo -e "Finished at $datetime"
2019-10-02 18:27:25 +02:00
done