Files
hakmem/scripts/rebuild_hakmem.sh

49 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "Usage: $0 [--hakx] [cycles ws seed]"
}
run_hakx=0
args=()
for arg in "$@"; do
case "$arg" in
--hakx)
run_hakx=1
;;
--help|-h)
usage
exit 0
;;
*)
args+=("$arg")
;;
esac
done
# Always run from repo root
top_dir="$(cd "$(dirname "$0")/.." && pwd)"
cd "$top_dir"
# Clean previous objects/binaries (safe deletion)
find "$top_dir" -maxdepth 1 -type f -name '*.o' -delete
find "$top_dir"/core -maxdepth 1 -type f -name '*.o' -delete
find "$top_dir" -maxdepth 1 -type f -name 'bench_*' -delete
rm -f libhakmem.a libhakmem.so
# Default benchmark parameters (optimized for memory efficiency)
# cycles=200000, working_set=400, seed=1
# Results: 12 MB RSS, 16 M ops/sec
if [[ ${#args[@]} -eq 0 ]]; then
args=(200000 400 1)
fi
if [[ $run_hakx -eq 1 ]]; then
make bench_random_mixed_hakx
LD_LIBRARY_PATH="$top_dir" taskset -c 0-3 /usr/bin/time -v ./bench_random_mixed_hakx "${args[@]}"
else
make bench_random_mixed_hakmem
LD_LIBRARY_PATH="$top_dir" taskset -c 0-3 /usr/bin/time -v ./bench_random_mixed_hakmem "${args[@]}"
fi