Update benchmark.sh

This commit is contained in:
Torma Kristóf 2019-04-26 14:32:55 +02:00 committed by GitHub
parent a4fbcf57e0
commit 9bbe3ddfc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,27 +6,30 @@ times=(1m)
kuberhost="node1:30765" kuberhost="node1:30765"
maxthreads=40 maxthreads=40
wave_connection=1 wave_dir_up=true
wave_connection=40
wave_max_conn=1600
wave_min_conn=40
wave_time="1m" wave_time="1m"
WRK_INSTALLED=$(which wrk) WRK_INSTALLED=$(command -v wrk)
if [[ $WRK_INSTALLED = "" ]] if [[ $WRK_INSTALLED = "" ]]
then then
apt update apt update
apt install build-essential libssl-dev git -y apt install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk git clone https://github.com/wg/wrk.git wrk
cd wrk cd wrk || exit
make make
cp wrk /usr/local/bin cp wrk /usr/local/bin
fi fi
HEY_INSTALLED=$(which hey) HEY_INSTALLED=$(command -v hey)
if [[ $HEY_INSTALLED = "" ]] if [[ $HEY_INSTALLED = "" ]]
then then
apt update apt update
apt install -y golang apt install -y golang
go get -u github.com/rakyll/hey go get -u github.com/rakyll/hey
cp $HOME/go/bin/hey /usr/local/bin cp "$HOME"/go/bin/hey /usr/local/bin
fi fi
if [[ $@ = *"--wave"* ]] if [[ $@ = *"--wave"* ]]
@ -34,10 +37,25 @@ then
while true; do while true; do
now=$(date '+%Y-%m-%d-%H-%M') now=$(date '+%Y-%m-%d-%H-%M')
echo -e "Running" echo -e "Running"
hey -c $wave_connection -z $wave_time -m POST -o csv -host "$function.kubeless" -D $function.body -T "application/json" http://$kuberhost/$function > ./$function.$now.wave.txt hey -c $wave_connection -z $wave_time -m POST -o csv -host "$function.kubeless" -D "$function".body -T "application/json" http://$kuberhost/"$function" > ./"$function"."$now".wave.txt
echo -e "Sleeping" echo -e "Sleeping"
sleep $time sleep "$time"
wave_connection=wave_connection * 2 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
done done
else else
echo -e "Benchmarking functions\n" echo -e "Benchmarking functions\n"
@ -45,14 +63,14 @@ for function in "${functions[@]}"
do do
echo -e "Benchmarking $function\n" echo -e "Benchmarking $function\n"
echo -e "Output of $function is:\n" echo -e "Output of $function is:\n"
perl -pi -e 'chomp if eof' $function.body 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 curl --data-binary @"$function".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
echo -e "\n" echo -e "\n"
for connection in "${connections[@]}" for connection in "${connections[@]}"
do do
if [[ $connection -lt $(($maxthreads + 1)) ]] if [[ $connection -lt $((maxthreads + 1)) ]]
then then
threads=$(($connection-1)) threads=$((connection-1))
else else
threads=$maxthreads threads=$maxthreads
fi fi
@ -62,12 +80,12 @@ do
datetime=$(date '+%Y-%m-%d-%H-%M-%S') datetime=$(date '+%Y-%m-%d-%H-%M-%S')
echo -e "Time: $time\n" echo -e "Time: $time\n"
echo -e "wrk\n" echo -e "wrk\n"
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 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
echo -e "hey-summary\n" echo -e "hey-summary\n"
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 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
echo -e "hey-csv\n" echo -e "hey-csv\n"
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 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 echo -e "$datetime"
done done
done done
done done