#!/bin/fish
set size (math "floor($argv[1] / 5)")
set iter (math "$argv[1] % 5")
set tokens "$(string repeat -n "$size" '@ ')"
set script "macro_rules! p{(\$(\$(@)+@)+$tokens)=>{fn main(){}}}p!(@ @ $tokens);"
set script "$(printf '---\npackage.edition="2024"\n---\n%s\n' "$script")"
set script_path scripts/test.$size.rs
printf "%s" "$script" >$script_path
set cargo_opts "+nightly" -Zscript --quiet \
    --config "build.incremental = false" \
    --config "build.target-dir = 'targets/$size.$iter'"
set time (/usr/bin/time -f '%e %M' -- cargo $cargo_opts $script_path 2>&1)
echo "$size $iter $time"
