Created
August 9, 2023 16:19
-
-
Save icu0755/a1363807d6e5134687484b5d7a9e8006 to your computer and use it in GitHub Desktop.
bash script that runs wrk2 against url with rate parameter from 1000 to 20000. The output is a table rate vs latency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if wrk2 is installed | |
if ! command -v wrk2 &> /dev/null; then | |
echo "wrk2 is not installed. Please install it: https://github.com/giltene/wrk2" | |
exit 1 | |
fi | |
# Check if an argument (URL) is provided | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <url>" | |
exit 1 | |
fi | |
URL="$1" | |
# Headers for the output table | |
printf "%-10s %-10s\n" "Rate" "Latency (ms)" | |
echo "----------------------" | |
# Loop through rates from 1000 to 20000 with steps of 1000 | |
for rate in {1000..20000..1000}; do | |
result=$(wrk2 -t4 -c100 -d30s -R${rate} -L ${URL} | grep Latency) | |
latency=$(echo $result | awk '{print $2}') | |
printf "%-10s %-10s\n" "$rate" "$latency" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment