#!/usr/bin/env bash
set -euo pipefail

# shellcheck source=../lib/common.sh
source "$(dirname "$0")/../lib/common.sh"
# shellcheck source=../lib/docker.sh
source "$(dirname "$0")/../lib/docker.sh"
# shellcheck source=../lib/bench.sh
source "$(dirname "$0")/../lib/bench.sh"

NAME="${1:-$LM_CONTAINER}"
BASE="${2:-$LM_URL}"
require_container "$NAME"

echo "=== Benchmark container: $NAME ==="
echo "URL: $BASE"
echo

echo "=== docker stats (trước) ==="
"${DOCKER[@]}" stats --no-stream --format \
  'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}' "$NAME"
print_container_limits "$NAME"
echo

echo "=== HTTP latency ==="
bench_http_suite "$BASE"

echo
echo "=== docker stats (sau) ==="
"${DOCKER[@]}" stats --no-stream --format \
  'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}' "$NAME"
