drop unused bench-create script + Makefile target

The script carried a python3 dep for one json.dumps on a VM name
that's always alphanumeric-plus-dashes anyway, it was never wired
into CI or docs, and `time banger vm create` covers the same need
ad hoc when anyone wants to measure create latency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thales Maciel 2026-04-20 13:33:09 -03:00
parent 58464ac28c
commit afe91e805a
No known key found for this signature in database
GPG key ID: 33112E6833C34679
2 changed files with 2 additions and 126 deletions

View file

@ -28,7 +28,7 @@ GO_LDFLAGS := -X banger/internal/buildinfo.Version=$(VERSION) -X banger/internal
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
.PHONY: help build banger bangerd test fmt tidy clean install uninstall bench-create lint lint-go lint-shell coverage coverage-html coverage-total .PHONY: help build banger bangerd test fmt tidy clean install uninstall lint lint-go lint-shell coverage coverage-html coverage-total
help: help:
@printf '%s\n' \ @printf '%s\n' \
@ -43,8 +43,7 @@ help:
' make lint Run gofmt + go vet + shellcheck (errors)' \ ' make lint Run gofmt + go vet + shellcheck (errors)' \
' make fmt Format Go sources under cmd/ and internal/' \ ' make fmt Format Go sources under cmd/ and internal/' \
' make tidy Run go mod tidy' \ ' make tidy Run go mod tidy' \
' make clean Remove built Go binaries and coverage artefacts' \ ' make clean Remove built Go binaries and coverage artefacts'
' make bench-create Benchmark vm create and SSH readiness with scripts/bench-create.sh'
build: $(BINARIES) build: $(BINARIES)
@ -102,9 +101,6 @@ tidy:
clean: clean:
rm -rf "$(BUILD_BIN_DIR)" coverage.out coverage.html rm -rf "$(BUILD_BIN_DIR)" coverage.out coverage.html
bench-create: build
BANGER_BIN="$(abspath $(BANGER_BIN))" bash ./scripts/bench-create.sh $(ARGS)
install: build install: build
mkdir -p "$(DESTDIR)$(BINDIR)" mkdir -p "$(DESTDIR)$(BINDIR)"
mkdir -p "$(DESTDIR)$(LIBDIR)/banger" mkdir -p "$(DESTDIR)$(LIBDIR)/banger"

View file

@ -1,120 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
log() {
printf '[bench-create] %s\n' "$*" >&2
}
usage() {
cat <<'EOF'
Usage: ./scripts/bench-create.sh [--runs N] [--image NAME] [--keep]
Measures:
- create_ms: time for `banger vm create`
- ssh_ready_ms: time until `banger vm ssh <vm> -- true` succeeds
EOF
}
RUNS=5
IMAGE_NAME=""
KEEP=0
while [[ $# -gt 0 ]]; do
case "$1" in
--runs)
RUNS="${2:-}"
shift 2
;;
--image)
IMAGE_NAME="${2:-}"
shift 2
;;
--keep)
KEEP=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
log "unknown option: $1"
usage
exit 1
;;
esac
done
if ! [[ "$RUNS" =~ ^[0-9]+$ ]] || [[ "$RUNS" -le 0 ]]; then
log "--runs must be a positive integer"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
if [[ -z "${BANGER_BIN:-}" ]]; then
if [[ -x "$REPO_ROOT/build/bin/banger" ]]; then
BANGER_BIN="$REPO_ROOT/build/bin/banger"
else
BANGER_BIN="$REPO_ROOT/banger"
fi
fi
if [[ ! -x "$BANGER_BIN" ]]; then
log "banger binary not found: $BANGER_BIN"
log "run 'make build' or set BANGER_BIN"
exit 1
fi
timestamp_ms() {
date +%s%3N
}
json_escape() {
python3 - <<'PY' "$1"
import json, sys
print(json.dumps(sys.argv[1]))
PY
}
printf '[\n'
for run in $(seq 1 "$RUNS"); do
vm_name="bench-$(date +%s)-$run"
create_args=("$BANGER_BIN" vm create --name "$vm_name")
if [[ -n "$IMAGE_NAME" ]]; then
create_args+=(--image "$IMAGE_NAME")
fi
create_start="$(timestamp_ms)"
if ! "${create_args[@]}" >/dev/null; then
log "create failed for $vm_name"
exit 1
fi
create_end="$(timestamp_ms)"
ssh_start="$create_end"
ssh_ready=0
deadline=$((ssh_start + 60000))
while (( $(timestamp_ms) < deadline )); do
if "$BANGER_BIN" vm ssh "$vm_name" -- true >/dev/null 2>&1; then
ssh_ready="$(timestamp_ms)"
break
fi
sleep 0.5
done
if [[ "$ssh_ready" -eq 0 ]]; then
log "ssh did not become ready for $vm_name"
exit 1
fi
if [[ "$KEEP" -ne 1 ]]; then
"$BANGER_BIN" vm delete "$vm_name" >/dev/null || true
fi
printf ' {"run": %d, "vm_name": %s, "create_ms": %d, "ssh_ready_ms": %d}%s\n' \
"$run" \
"$(json_escape "$vm_name")" \
"$((create_end - create_start))" \
"$((ssh_ready - create_start))" \
"$( [[ "$run" -lt "$RUNS" ]] && printf ',' )"
done
printf ']\n'