#!/bin/bash # memseq.sh ID FRAMES OUTDIR [ENV=VAL ...]: a sequence render of shot ID's first FRAMES frames, its footprint split by # category every 2 s (MB: total, malloc large, malloc small, graphics), raea's marks each frame; the frames removed. # RAEA_BIN: the binary (a copy, never target/). set -uo pipefail id=$1; n=$2; out=$3; shift 3 cd ~/Documents/raea/raea/projects/halcyon-motel mkdir -p "$out"; : >"$out/cats.txt" env RAEA_MEM_MARKS=1 RAEA_MEM_MARKS_EVERY=1 "$@" "${RAEA_BIN:-$HOME/raea/target/release/raea}" render compositions/reel.tsx --composition "shot-$id" $( [ "$n" = all ] || echo --frames "$n" ) -o "$out/frames/" >"$out/render.log" 2>&1 & pid=$! t0=$(date +%s) while kill -0 "$pid" 2>/dev/null; do footprint -p "$pid" -f bytes 2>/dev/null | awk -v t=$(($(date +%s) - t0)) ' /Footprint:/ { for (i = 1; i <= NF; i++) if ($i == "Footprint:") tot = $(i + 1) } /Malloc Large$/ { ml = $1 } /Malloc Small$/ { ms = $1 } /\(graphics\)$/ { g += $1 } END { printf "%4ds total %6d mallocL %6d mallocS %6d gpu %6d\n", t, tot / 1048576, ml / 1048576, ms / 1048576, g / 1048576 }' >>"$out/cats.txt" sleep 2 done wait "$pid"; echo "exit $?" d="$out/frames"; rm -rf "${d:?}"