Phase 21.7 normalization: optimization pre-work + bench harness expansion
- Add opt-in optimizations (defaults OFF) - Ret purity verifier: NYASH_VERIFY_RET_PURITY=1 - strlen FAST enhancement for const handles - FAST_INT gate for same-BB SSA optimization - length cache for string literals in llvmlite - Expand bench harness (tools/perf/microbench.sh) - Add branch/call/stringchain/arraymap/chip8/kilo cases - Auto-calculate ratio vs C reference - Document in benchmarks/README.md - Compiler health improvements - Unify PHI insertion to insert_phi_at_head() - Add NYASH_LLVM_SKIP_BUILD=1 for build reuse - Runtime & safety enhancements - Clarify Rust/Hako ownership boundaries - Strengthen receiver localization (LocalSSA/pin/after-PHIs) - Stop excessive PluginInvoke→BoxCall rewrites - Update CURRENT_TASK.md, docs, and canaries 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
39
tools/perf/bench_ny_mir_builder.sh
Normal file
39
tools/perf/bench_ny_mir_builder.sh
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# bench_ny_mir_builder.sh — Quick micro-bench for MIR(JSON) → {obj|exe}
|
||||
# Usage: tools/perf/bench_ny_mir_builder.sh <mir.json> [rounds]
|
||||
# Notes:
|
||||
# - Uses crate backend (ny-llvmc). Keeps defaults conservative (O0).
|
||||
# - Prints simple CSV: kind,round,ms
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: $0 <mir.json> [rounds]" >&2
|
||||
exit 2
|
||||
fi
|
||||
IN="$1"; ROUNDS="${2:-3}"
|
||||
|
||||
BIN_BUILDER="tools/ny_mir_builder.sh"
|
||||
if [[ ! -x "$BIN_BUILDER" ]]; then echo "error: $BIN_BUILDER not found/executable" >&2; exit 2; fi
|
||||
|
||||
measure() {
|
||||
local kind="$1"; shift
|
||||
local out_path="$PWD/target/aot_objects/__bench_${kind}_$$"
|
||||
[[ "$kind" == "exe" ]] && out_path+=".out" || out_path+=".o"
|
||||
local start end ms
|
||||
start=$(date +%s%3N)
|
||||
NYASH_LLVM_BACKEND=crate "$BIN_BUILDER" --in "$IN" --emit "$kind" -o "$out_path" --quiet || return 1
|
||||
end=$(date +%s%3N)
|
||||
ms=$((end - start))
|
||||
rm -f "$out_path" 2>/dev/null || true
|
||||
echo "$kind,$ms"
|
||||
}
|
||||
|
||||
echo "kind,round,ms"
|
||||
for k in obj exe; do
|
||||
for ((i=1; i<=ROUNDS; i++)); do
|
||||
line=$(measure "$k" || echo "$k,ERROR")
|
||||
echo "$k,$i,${line#*,}"
|
||||
done
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user