Update benchmark.sh

This commit is contained in:
Torma Kristóf 2019-04-03 12:39:30 +02:00 committed by GitHub
parent abf0e111be
commit 4f857e20ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,23 @@ times=(1m)
data=(isprime) data=(isprime)
kuberhost="node1:32764" kuberhost="node1:32764"
maxthreads=160 maxthreads=160
wrk_options="-t$threads -d$time -c$connection -H"Host: $function.kubeless" -H"Content-Type:application/json" --latency http://$kuberhost/$function"
wrk_output=$function.$connection.$time.txt
hey_options="-z $time -c $connection -o csv -m POST -host "$function.kubeless" -T "application/json" http://$kuberhost/$function"
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
}
WRK_INSTALLED=$(which wrk) WRK_INSTALLED=$(which wrk)
if [ "$WRK_INSTALLED" = "" ] if [ "$WRK_INSTALLED" = "" ]
@ -32,8 +49,12 @@ 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"
curl --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/$function array_contains data function && perl -pi -e 'chomp if eof' $function.body
curl_additional_options=$(array_contains data function && "--data-binary "@$function.body"")
curl $curl_additional_options --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/$function
echo -e "\n" echo -e "\n"
wrk_additional_options=$(array_contains data function && "-s$function.wrk")
hey_additional_options=$(array_contains data function && "-D $function.body")
for connection in "${connections[@]}" for connection in "${connections[@]}"
do do
if [[ $connection -lt $(($maxthreads + 1)) ]] if [[ $connection -lt $(($maxthreads + 1)) ]]
@ -46,34 +67,8 @@ do
for time in "${times[@]}" for time in "${times[@]}"
do do
echo -e "Time: $time\n" echo -e "Time: $time\n"
wrk -t$threads -d$time -c$connection -H"Host: $function.kubeless" -H"Content-Type:application/json" --latency http://$kuberhost/$function > ./$function.$connection.$time.txt 2>&1 wrk $wrk_options $wrk_additional_options > $wrk_output 2>&1
hey -z $time -c $connection -o csv -m POST -host "$function.kubeless" -T "application/json" http://$kuberhost/$function > $function.$connection.$time.csv hey $hey_options $hey_additional_options > $hey_output
done
done
done
echo -e "Benchmarking POST functions\n"
for function in "${data[@]}"
do
echo -e "Benchmarking $function\n"
echo -e "Output of $function is:\n"
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
echo -e "\n"
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[@]}"
do
echo -e "Time: $time\n"
wrk -t$threads -d$time -c$connection -s$function.wrk -H"Host: $function.kubeless" -H"Content-Type:application/json" --latency http://$kuberhost/$function > ./$function.$connection.$time.txt 2>&1
hey -z $time -c $connection -o csv -m POST -host "$function.kubeless" -T "application/json" -D $function.body http://$kuberhost/$function > $function.$connection.$time.csv
done done
done done
done done