mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-26 10:18:29 +02:00
refactor(benchmark): restart bench server after each run
This commit is contained in:
4
Makefile
4
Makefile
@@ -125,9 +125,9 @@ dev-build: build
|
||||
|
||||
benchmark:
|
||||
@if [ -z "$(TARGET)" ]; then \
|
||||
docker compose -f dev.compose.yml up -d --force-recreate whoami godoxy traefik caddy nginx; \
|
||||
docker compose -f dev.compose.yml up -d --force-recreate godoxy traefik caddy nginx; \
|
||||
else \
|
||||
docker compose -f dev.compose.yml up -d --force-recreate whoami $(TARGET); \
|
||||
docker compose -f dev.compose.yml up -d --force-recreate $(TARGET); \
|
||||
fi
|
||||
sleep 1
|
||||
@./scripts/benchmark.sh
|
||||
|
||||
@@ -9,7 +9,7 @@ HOST="bench.domain.com"
|
||||
DURATION="${DURATION:-10s}"
|
||||
THREADS="${THREADS:-4}"
|
||||
CONNECTIONS="${CONNECTIONS:-100}"
|
||||
TARGET="${TARGET:-}"
|
||||
TARGET="${TARGET-}"
|
||||
|
||||
# Color functions for output
|
||||
red() { echo -e "\033[0;31m$*\033[0m"; }
|
||||
@@ -18,7 +18,7 @@ yellow() { echo -e "\033[1;33m$*\033[0m"; }
|
||||
blue() { echo -e "\033[0;34m$*\033[0m"; }
|
||||
|
||||
# Check if wrk is installed
|
||||
if ! command -v wrk &> /dev/null; then
|
||||
if ! command -v wrk &>/dev/null; then
|
||||
red "Error: wrk is not installed"
|
||||
echo "Please install wrk:"
|
||||
echo " Ubuntu/Debian: sudo apt-get install wrk"
|
||||
@@ -27,7 +27,7 @@ if ! command -v wrk &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v h2load &> /dev/null; then
|
||||
if ! command -v h2load &>/dev/null; then
|
||||
red "Error: h2load is not installed"
|
||||
echo "Please install h2load (nghttp2-client):"
|
||||
echo " Ubuntu/Debian: sudo apt-get install nghttp2-client"
|
||||
@@ -36,7 +36,7 @@ if ! command -v h2load &> /dev/null; then
|
||||
fi
|
||||
|
||||
OUTFILE="/tmp/reverse_proxy_benchmark_$(date +%Y%m%d_%H%M%S).log"
|
||||
: > "$OUTFILE"
|
||||
: >"$OUTFILE"
|
||||
exec > >(tee -a "$OUTFILE") 2>&1
|
||||
|
||||
blue "========================================"
|
||||
@@ -133,12 +133,22 @@ echo ""
|
||||
blue "========================================"
|
||||
echo ""
|
||||
|
||||
restart_bench() {
|
||||
local name=$1
|
||||
echo ""
|
||||
yellow "Restarting bench service before benchmarking $name HTTP/1.1..."
|
||||
docker compose -f dev.compose.yml up -d --force-recreate bench >/dev/null 2>&1
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# Function to run benchmark
|
||||
run_benchmark() {
|
||||
local name=$1
|
||||
local url=$2
|
||||
local h2_duration="${DURATION%s}"
|
||||
|
||||
restart_bench "$name"
|
||||
|
||||
yellow "Testing $name..."
|
||||
|
||||
echo "========================================"
|
||||
@@ -152,6 +162,8 @@ run_benchmark() {
|
||||
-H "Host: $HOST" \
|
||||
"$url"
|
||||
|
||||
restart_bench "$name"
|
||||
|
||||
echo ""
|
||||
echo "[HTTP/2] h2load"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user