From 4f857e20ee714cdff1f7b5406e846fe8c3f524b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Wed, 3 Apr 2019 12:39:30 +0200 Subject: [PATCH] Update benchmark.sh --- benchmark/benchmark.sh | 53 +++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/benchmark/benchmark.sh b/benchmark/benchmark.sh index 2aa3294..92cb456 100644 --- a/benchmark/benchmark.sh +++ b/benchmark/benchmark.sh @@ -6,6 +6,23 @@ times=(1m) data=(isprime) kuberhost="node1:32764" 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) if [ "$WRK_INSTALLED" = "" ] @@ -32,8 +49,12 @@ for function in "${functions[@]}" do echo -e "Benchmarking $function\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" + wrk_additional_options=$(array_contains data function && "-s$function.wrk") + hey_additional_options=$(array_contains data function && "-D $function.body") for connection in "${connections[@]}" do if [[ $connection -lt $(($maxthreads + 1)) ]] @@ -46,34 +67,8 @@ do for time in "${times[@]}" do 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 - hey -z $time -c $connection -o csv -m POST -host "$function.kubeless" -T "application/json" http://$kuberhost/$function > $function.$connection.$time.csv - 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 + wrk $wrk_options $wrk_additional_options > $wrk_output 2>&1 + hey $hey_options $hey_additional_options > $hey_output done done done