refarctor benchmark
This commit is contained in:
parent
350f077ca4
commit
06a9a57c88
@ -1,7 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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
|
#Configuration variables
|
||||||
functions=(isprime-kubeless-go-sc)
|
functions=(isprime-kubeless-go-sc)
|
||||||
@ -11,177 +8,109 @@ kuberhost="node1:31299"
|
|||||||
maxthreads=40
|
maxthreads=40
|
||||||
kubeless=true
|
kubeless=true
|
||||||
rps=500
|
rps=500
|
||||||
#Wave mode configuration
|
|
||||||
wave_connection=40
|
|
||||||
wave_max_conn=160
|
|
||||||
wave_min_conn=40
|
|
||||||
wave_time="30s"
|
|
||||||
wave_loop_max=2
|
|
||||||
#Climb mode configuration
|
#Climb mode configuration
|
||||||
climb_max=10
|
climb_max=10
|
||||||
climb=1
|
climb=1
|
||||||
|
|
||||||
HEY_INSTALLED=$(command -v 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
|
||||||
|
|
||||||
LOADTEST_INSTALLED=$(command -v loadtest)
|
LOADTEST_INSTALLED=$(command -v loadtest)
|
||||||
if [[ LOADTEST_INSTALLED = "" ]]
|
if [[ LOADTEST_INSTALLED == "" ]]; then
|
||||||
then
|
apt update
|
||||||
apt update
|
apt install -y nodejs npm
|
||||||
apt install -y nodejs npm
|
npm i -g loadtest
|
||||||
npm i -g loadtest
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "Benchmarking functions\n"
|
echo -e "Benchmarking functions\n"
|
||||||
for function in "${functions[@]}"
|
for function in "${functions[@]}"; do
|
||||||
do
|
|
||||||
function_friendly=$(echo $function | cut - -d'-' -f1)
|
function_friendly=$(echo $function | cut - -d'-' -f1)
|
||||||
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_friendly".body
|
perl -pi -e 'chomp if eof' "$function_friendly".body
|
||||||
if $kubeless;
|
if $kubeless; then
|
||||||
then
|
|
||||||
curl --data-binary @"$function_friendly".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
|
curl --data-binary @"$function_friendly".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
|
||||||
else
|
else
|
||||||
curl --header "Host: $function.default.example.com" http://$kuberhost/
|
curl --header "Host: $function.default.example.com" http://$kuberhost/
|
||||||
fi
|
fi
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
if [[ $* = *"--wave"* ]]
|
for connection in "${connections[@]}"; do
|
||||||
then
|
if [[ $connection -lt $((maxthreads + 1)) ]]; then
|
||||||
wave_loop=1
|
threads=$((connection - 1))
|
||||||
wave_dir_up=true
|
else
|
||||||
wave_num=1
|
threads=$maxthreads
|
||||||
while [[ $wave_loop -lt $wave_loop_max ]]; do
|
fi
|
||||||
now=$(date '+%Y-%m-%d-%H-%M')
|
echo -e "Threads: $threads Connections $connection\n"
|
||||||
echo -e "Connections: $wave_connection"
|
for time in "${times[@]}"; do
|
||||||
echo -e "Running"
|
datetime=$(date '+%Y-%m-%d-%H-%M-%S')
|
||||||
if $kubeless;
|
echo -e "Time: $time\n"
|
||||||
then
|
if [[ $* == *"--fire"* ]]; then
|
||||||
hey -c $wave_connection -q $rps -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
|
echo -e "hey-summary $datetime\n"
|
||||||
else
|
if $kubeless; then
|
||||||
hey -c $wave_connection -q $rps -z $wave_time -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$wave_num".wave.csv
|
if [[ $* == *"--loadtest"* ]]; then
|
||||||
fi
|
loadtest -H "Host: $function.kubeless" --rps $rps -c $connection -t $time -p "$function_firendly".body http://$kuberhost/"$function" >./data/"$function"."$connection"."$time"."$datetime".txt
|
||||||
wave_num=$((wave_num + 1))
|
|
||||||
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
|
else
|
||||||
echo -e "Not stepping"
|
hey -c "$connection" -q $rps -z "$time" -m POST -host "$function.kubeless" -D "$function_firendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$connection"."$time"."$datetime".txt
|
||||||
wave_dir_up=true
|
fi
|
||||||
wave_loop=$((wave_loop + 1))
|
else
|
||||||
|
if [[ $* == *"--loadtest"* ]]; then
|
||||||
|
loadtest -H "Host: $function.default.example.com" --rps $rps -c $connection -t $time http://$kuberhost/ >./data/"$function"."$connection"."$time"."$datetime".txt
|
||||||
|
else
|
||||||
|
hey -c "$connection" -q $rps -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$connection"."$time"."$datetime".txt
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
else
|
|
||||||
for connection in "${connections[@]}"
|
|
||||||
do
|
|
||||||
if [[ $connection -lt $((maxthreads + 1)) ]]
|
|
||||||
then
|
|
||||||
threads=$((connection-1))
|
|
||||||
else
|
|
||||||
threads=$maxthreads
|
|
||||||
fi
|
fi
|
||||||
echo -e "Threads: $threads Connections $connection\n"
|
if [[ $* == *"--csv"* ]]; then
|
||||||
for time in "${times[@]}"
|
echo -e "hey-csv $datetime\n"
|
||||||
do
|
if $kubeless; then
|
||||||
datetime=$(date '+%Y-%m-%d-%H-%M-%S')
|
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".csv
|
||||||
echo -e "Time: $time\n"
|
else
|
||||||
if [[ $* = *"--fire"* ]]
|
hey -c "$connection" -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$connection"."$time"."$datetime".csv
|
||||||
then
|
fi
|
||||||
echo -e "hey-summary $datetime\n"
|
fi
|
||||||
if $kubeless;
|
if [[ $* == *"--for"* ]]; then
|
||||||
then
|
for num in 1 2 3 4 5 6 7 8 9 10; do
|
||||||
if [[ $* = *"--loadtest"* ]]
|
echo -e "hey-for $num\n"
|
||||||
then
|
if $kubeless; then
|
||||||
loadtest -H "Host: $function.kubeless" --rps $rps -c $connection -t $time -p "$function_firendly".body http://$kuberhost/"$function" > ./data/"$function"."$connection"."$time"."$datetime".txt
|
if [[ $* == *"--loadtest"* ]]; then
|
||||||
else
|
loadtest -H "Host: $function.kubeless" --rps $rps -c $connection -t $time -p "$function_firendly".body http://$kuberhost/"$function" >./data/"$function"."$num".txt
|
||||||
hey -c "$connection" -q $rps -z "$time" -m POST -host "$function.kubeless" -D "$function_firendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$connection"."$time"."$datetime".txt
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [[ $* = *"--loadtest"* ]]
|
hey -c "$connection" -q $rps -z "$time" -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$num".csv
|
||||||
then
|
fi
|
||||||
loadtest -H "Host: $function.default.example.com" --rps $rps -c $connection -t $time http://$kuberhost/ > ./data/"$function"."$connection"."$time"."$datetime".txt
|
else
|
||||||
else
|
if [[ $* == *"--loadtest"* ]]; then
|
||||||
hey -c "$connection" -q $rps -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$connection"."$time"."$datetime".txt
|
loadtest -H "Host: $function.default.example.com" --rps $rps -c $connection -t $time http://$kuberhost/ >./data/"$function"."$num".for.csv
|
||||||
fi
|
else
|
||||||
|
hey -c "$connection" -q $rps -z "$time" -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$num".for.csv
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ $* = *"--csv"* ]]
|
done
|
||||||
then
|
fi
|
||||||
echo -e "hey-csv $datetime\n"
|
|
||||||
if $kubeless;
|
|
||||||
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".csv
|
|
||||||
else
|
|
||||||
hey -c "$connection" -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$connection"."$time"."$datetime".csv
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ $* = *"--for"* ]]
|
|
||||||
then
|
|
||||||
for num in 1 2 3 4 5 6 7 8 9 10
|
|
||||||
do
|
|
||||||
echo -e "hey-for $num\n"
|
|
||||||
if $kubeless;
|
|
||||||
then
|
|
||||||
if [[ $* = *"--loadtest"* ]]
|
|
||||||
then
|
|
||||||
loadtest -H "Host: $function.kubeless" --rps $rps -c $connection -t $time -p "$function_firendly".body http://$kuberhost/"$function" > ./data/"$function"."$num".txt
|
|
||||||
else
|
|
||||||
hey -c "$connection" -q $rps -z "$time" -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$num".csv
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ $* = *"--loadtest"* ]]
|
|
||||||
then
|
|
||||||
loadtest -H "Host: $function.default.example.com" --rps $rps -c $connection -t $time http://$kuberhost/ > ./data/"$function"."$num".for.csv
|
|
||||||
else
|
|
||||||
hey -c "$connection" -q $rps -z "$time" -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$num".for.csv
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
fi
|
done
|
||||||
if [[ $* = *"--climb"* ]]
|
if [[ $* == *"--climb"* ]]; then
|
||||||
then
|
|
||||||
while [[ $climb -lt $climb_max ]]; do
|
while [[ $climb -lt $climb_max ]]; do
|
||||||
climb_rps=$((rps * climb))
|
climb_rps=$((rps * climb))
|
||||||
echo -e "Connections: $climb_connection"
|
echo -e "Connections: $climb_connection"
|
||||||
if $kubeless;
|
if $kubeless; then
|
||||||
then
|
if [[ $* == *"--loadtest"* ]]; then
|
||||||
if [[ $* = *"--loadtest"* ]]
|
loadtest -H "Host: $function.kubeless" --rps $climb_rps -c 1 -t $time -p "$function_firendly".body http://$kuberhost/"$function" >./data/"$function"."$climb_connection".climb.txt
|
||||||
then
|
|
||||||
loadtest -H "Host: $function.kubeless" --rps $climb_rps -c 1 -t $time -p "$function_firendly".body http://$kuberhost/"$function" > ./data/"$function"."$climb_connection".climb.txt
|
|
||||||
else
|
else
|
||||||
hey -c 1 -q $climb_rps -z $time -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$climb_connection".climb.csv
|
hey -c 1 -q $climb_rps -z $time -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$climb_connection".climb.csv
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [[ $* == *"--loadtest"* ]]; then
|
||||||
|
loadtest -H "Host: $function.default.example.com" --rps $climb_rps -c 1 -t $time http://$kuberhost/ >./data/"$function"."$climb_connection".climb.txt
|
||||||
else
|
else
|
||||||
if [[ $* = *"--loadtest"* ]]
|
hey -c 1 -q $climb_rps -z $time -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$climb_connection".climb.csv
|
||||||
then
|
|
||||||
loadtest -H "Host: $function.default.example.com" --rps $climb_rps -c 1 -t $time http://$kuberhost/ > ./data/"$function"."$climb_connection".climb.txt
|
|
||||||
else
|
|
||||||
hey -c 1 -q $climb_rps -z $time -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ > ./data/"$function"."$climb_connection".climb.csv
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
climb=$((climb + 1))
|
climb=$((climb + 1))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "Finished at $datetime"
|
echo -e "Finished at $datetime"
|
||||||
|
Loading…
Reference in New Issue
Block a user