Update docker/auth-bench/run-ab.sh

This commit is contained in:
colin 2024-02-20 21:25:51 +00:00
parent b1193f7c7a
commit 608accc549
1 changed files with 4 additions and 4 deletions

View File

@ -18,21 +18,21 @@ function run_apache_bench_and_check_ttfb {
local total_ttfb=0 local total_ttfb=0
local ttfb=0 local ttfb=0
echo "URL, Average TTFB, AB Mean Time per Request" | tee "$log_file" echo "URL,Average TTFB (ms),AB Mean Time per Request (ms)" | tee "$log_file"
for url in "${urls[@]}"; do for url in "${urls[@]}"; do
total_ttfb=0 total_ttfb=0
ab_summary=$(ab -n "$requests" -c "$concurrency" -A "$username:$password" "$url" 2>&1 | grep "Time per request" | head -1) ab_summary=$(ab -n "$requests" -c "$concurrency" -A "$username:$password" "$url" 2>&1 | grep "Time per request" | head -1)
ab_mean_time_per_request=$(echo "$ab_summary" | awk '{print $4 " " $5}') ab_mean_time_per_request=$(echo "$ab_summary" | awk '{print $4}')
for i in {1..5}; do for i in {1..5}; do
ttfb=$(curl -o /dev/null -s -w "%{time_starttransfer}\n" -u "$username:$password" "$url") ttfb=$(curl -o /dev/null -s -w "%{time_starttransfer}\n" -u "$username:$password" "$url")
total_ttfb=$(echo "$total_ttfb + $ttfb" | bc) total_ttfb=$(echo "$total_ttfb + $ttfb" | bc)
done done
local mean_ttfb=$(echo "scale=3; $total_ttfb / 5" | bc) local mean_ttfb=$(echo "scale=3; $total_ttfb / 5 * 1000" | bc)
echo "$url, $mean_ttfb, $ab_mean_time_per_request" | tee -a "$log_file" echo "$url,$mean_ttfb,${ab_mean_time_per_request}" | tee -a "$log_file"
done done
} }