#!/usr/bin/env bash set -euo pipefail # Plan A: Minimal bench/docs reorg into benchmarks/{src,bin,logs,scripts} # Non-destructive: backs up to .reorg_backup if targets exist. ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT_DIR" mkdir -p benchmarks/{src,bin,logs,scripts} backup() { local f="$1"; local dest="$2"; if [[ -e "$f" ]]; then if [[ -e "$dest/$(basename "$f")" ]]; then mkdir -p .reorg_backup mv -f "$f" .reorg_backup/ else mv -f "$f" "$dest/" fi fi } # Source files (if exist) for f in bench_allocators.c memset_test.c pf_test.c test_*.c; do for ff in $f; do [[ -e "$ff" ]] && backup "$ff" benchmarks/src done done # Binaries for f in bench_allocators bench_allocators_hakmem bench_allocators_system memset_test pf_test test_*; do for ff in $f; do [[ -x "$ff" ]] && backup "$ff" benchmarks/bin done done # Logs (simple *.log) shopt -s nullglob for ff in *.log; do backup "$ff" benchmarks/logs done # Scripts (runner) for f in bench_runner.sh run_full_benchmark.sh; do [[ -e "$f" ]] && backup "$f" benchmarks/scripts done echo "Reorg Plan A completed. See benchmarks/{src,bin,logs,scripts} and .reorg_backup/ if any conflicts."