Update docker/auth-bench/run-ab.sh
This commit is contained in:
parent
c5f135f33f
commit
17a6c5af55
|
@ -27,19 +27,23 @@ function check_ttfb_and_log {
|
||||||
local password=$PASSWORD
|
local password=$PASSWORD
|
||||||
local log_file="/logs/authenticated.csv"
|
local log_file="/logs/authenticated.csv"
|
||||||
local total_ttfb sum_ttfb mean_ttfb http_code
|
local total_ttfb sum_ttfb mean_ttfb http_code
|
||||||
echo "URL,Username,HTTP Code,Mean TTFB" > "$log_file"
|
|
||||||
|
echo "URL,Username,Mean TTFB,HTTP Code" > "$log_file"
|
||||||
|
|
||||||
for url in "${urls[@]}"; do
|
for url in "${urls[@]}"; do
|
||||||
total_ttfb=0
|
total_ttfb=0
|
||||||
for i in {1..5}; do
|
for i in {1..5}; do
|
||||||
response=$(curl -o /dev/null -s -w "%{http_code},%{time_starttransfer}\n" -u "$username:$password" "$url")
|
response=$(curl -o /dev/null -s -w "%{time_starttransfer},%{http_code}\n" -u "$username:$password" "$url")
|
||||||
http_code=$(echo "$response" | cut -d',' -f1)
|
IFS=',' read -r ttfb http_code <<< "$response"
|
||||||
ttfb=$(echo "$response" | cut -d',' -f2)
|
|
||||||
total_ttfb=$(echo "$total_ttfb + $ttfb" | bc)
|
total_ttfb=$(echo "$total_ttfb + $ttfb" | bc)
|
||||||
done
|
done
|
||||||
sum_ttfb=$total_ttfb
|
sum_ttfb=$total_ttfb
|
||||||
mean_ttfb=$(echo "scale=3; $sum_ttfb / 5" | bc)
|
mean_ttfb=$(echo "scale=3; $sum_ttfb / 5" | bc)
|
||||||
echo "$url,$username,$http_code,$mean_ttfb" | tee -a "$log_file"
|
echo "$url,$username,$mean_ttfb,$http_code" >> "$log_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
local haste_url=$(curl -X POST -s -F "file=@${log_file}" https://haste.nixc.us/documents | awk -F '"' '{print "https://haste.nixc.us/"$4}')
|
||||||
|
echo "Logs uploaded to: $haste_url"
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_log_file {
|
function prepare_log_file {
|
||||||
|
@ -50,7 +54,6 @@ function prepare_log_file {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_log_file
|
prepare_log_file
|
||||||
|
|
||||||
test_urls
|
test_urls
|
||||||
run_apache_bench
|
run_apache_bench
|
||||||
check_ttfb_and_log
|
check_ttfb_and_log
|
||||||
|
|
Loading…
Reference in New Issue