Skip to content

Instantly share code, notes, and snippets.

@icu0755
Created August 9, 2023 15:30
Show Gist options
  • Save icu0755/23ba8281e1ab111e2f84178023b9d6e8 to your computer and use it in GitHub Desktop.
Save icu0755/23ba8281e1ab111e2f84178023b9d6e8 to your computer and use it in GitHub Desktop.
Below is an example of a Bash script that takes a URL as input and uses the wrk2 tool to run benchmarking against that URL. Please make sure you have wrk2 installed on your system before using this script.
#!/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 to test
URL="$1"
# Other wrk2 options you can customize
THREADS=4
CONNECTIONS=100
DURATION=30s
# Run wrk2 benchmark
wrk2 -t${THREADS} -c${CONNECTIONS} -d${DURATION} ${URL}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment