#!/usr/bin/env bash set -euo pipefail # Sampling profiler sweep across size ranges and threads. # Default: short 2s runs; adjust with -d. RUNTIME=2 THREADS="1,4" CHUNK_PER_THREAD=10000 ROUNDS=1 SAMPLE_N=8 # 1/256 MIN="" MAX="" usage() { cat << USAGE Usage: scripts/prof_sweep.sh [options] -d SEC runtime seconds (default: 2) -t CSV threads CSV (default: 1,4) -s N HAKMEM_PROF_SAMPLE exponent (default: 8 → 1/256) -m BYTES min size override (optional) -M BYTES max size override (optional) Runs with HAKMEM_PROF=1 and prints profiler summary for each case. USAGE } while getopts ":d:t:s:m:M:h" opt; do case $opt in d) RUNTIME="$OPTARG" ;; t) THREADS="$OPTARG" ;; s) SAMPLE_N="$OPTARG" ;; m) MIN="$OPTARG" ;; M) MAX="$OPTARG" ;; h) usage; exit 0 ;; :) echo "Missing arg -$OPTARG"; usage; exit 2 ;; *) usage; exit 2 ;; esac done ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" LARSON="$ROOT_DIR/mimalloc-bench/bench/larson/larson" LIB="$(readlink -f "$ROOT_DIR/libhakmem.so")" if [[ ! -x "$LARSON" ]]; then echo "larson not found: $LARSON" >&2; exit 1 fi runs=( "tiny:8:1024" "mid:2048:32768" "gap:33000:65536" "large:65536:1048576" "big:2097152:4194304" ) IFS=',' read -r -a TARR <<< "$THREADS" echo "[CFG] runtime=$RUNTIME sample=1/$((1<&1 \ | tail -n 80 done done echo "\nSweep done."