From afe91e805a5fb45f40f063305a967b96840c4feb Mon Sep 17 00:00:00 2001 From: Thales Maciel Date: Mon, 20 Apr 2026 13:33:09 -0300 Subject: [PATCH] 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) --- Makefile | 8 +-- scripts/bench-create.sh | 120 ---------------------------------------- 2 files changed, 2 insertions(+), 126 deletions(-) delete mode 100644 scripts/bench-create.sh diff --git a/Makefile b/Makefile index a57d542..bf2954c 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ GO_LDFLAGS := -X banger/internal/buildinfo.Version=$(VERSION) -X banger/internal .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: @printf '%s\n' \ @@ -43,8 +43,7 @@ help: ' make lint Run gofmt + go vet + shellcheck (errors)' \ ' make fmt Format Go sources under cmd/ and internal/' \ ' make tidy Run go mod tidy' \ - ' make clean Remove built Go binaries and coverage artefacts' \ - ' make bench-create Benchmark vm create and SSH readiness with scripts/bench-create.sh' + ' make clean Remove built Go binaries and coverage artefacts' build: $(BINARIES) @@ -102,9 +101,6 @@ tidy: clean: 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 mkdir -p "$(DESTDIR)$(BINDIR)" mkdir -p "$(DESTDIR)$(LIBDIR)/banger" diff --git a/scripts/bench-create.sh b/scripts/bench-create.sh deleted file mode 100644 index ff30290..0000000 --- a/scripts/bench-create.sh +++ /dev/null @@ -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 -- 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'