brewery
notashelf /
b3dcba607b58c70a5cb4245e29ed315abd0b3db7

nixir

public

Import-resolving Nix IR plugin

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/nixir.git

Commit b3dcba607b58

tarball

NotAShelf <raf@notashelf.dev> · 2026-04-24 20:13 UTC

unverified1 files changed+38-2
tests/benchmark: fine-grain timing reports

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia481b0129193540636665340bd257d136a6a6964
diff --git a/tests/benchmark/run.sh b/tests/benchmark/run.shindex d59b497..8e43fe8 100755--- a/tests/benchmark/run.sh+++ b/tests/benchmark/run.sh@@ -32,8 +32,8 @@ run_benchmark() { 	echo -e "${BLUE}=== $name ===${NC}" 	echo "" -	# Measure compilation time-	echo -n "  Compilation time:     "+	# Measure compilation time only+	echo -n "  Compilation only:     " 	local compile_start 	compile_start=$(date +%s%N) 	"$IRC_BIN" "$file" /tmp/bench.nixir >/dev/null 2>&1@@ -42,6 +42,42 @@ run_benchmark() { 	local compile_ms=$(((compile_end - compile_start) / 1000000)) 	echo -e "${YELLOW}${compile_ms}ms${NC}" +	# Measure IR loading only (deserialization + evaluation)+	echo -n "  IR load only:         "+	PLUGIN_PATH="$(pwd)/build/nix-ir-plugin.so"+	if [ ! -f "$PLUGIN_PATH" ]; then+		echo -e "${YELLOW}skipped${NC} (plugin not built)"+	else+		# Pre-compile the IR+		"$IRC_BIN" "$file" /tmp/bench.nixir >/dev/null 2>&1++		# Measure just the loading (average of 10 runs to reduce noise)+		local total_load_us=0+		for _ in {1..10}; do+			local load_output+			load_output=$(nix-instantiate --plugin-files "$PLUGIN_PATH" --eval --expr "builtins.nixIR_loadIR \"/tmp/bench.nixir\"" 2>&1 >/dev/null | grep "nixIR timing" | grep -oP 'total=\K[0-9]+')+			total_load_us=$((total_load_us + load_output))+		done+		local avg_load_us=$((total_load_us / 10))+		local avg_load_ms_frac=$(awk "BEGIN {printf \"%.3f\", $avg_load_us / 1000}")+		echo -e "${GREEN}${avg_load_ms_frac}ms${NC} avg (10 runs)"+	fi++	# Measure full pipeline (compile + nix-instantiate overhead + IR load)+	echo -n "  Full pipeline:        "+	if [ ! -f "$PLUGIN_PATH" ]; then+		echo -e "${YELLOW}skipped${NC}"+	else+		local pipeline_start+		pipeline_start=$(date +%s%N)+		"$IRC_BIN" "$file" /tmp/bench.nixir >/dev/null 2>&1+		nix-instantiate --plugin-files "$PLUGIN_PATH" --eval --expr "builtins.nixIR_loadIR \"/tmp/bench.nixir\"" >/dev/null 2>&1+		local pipeline_end+		pipeline_end=$(date +%s%N)+		local pipeline_ms=$(((pipeline_end - pipeline_start) / 1000000))+		echo -e "${YELLOW}${pipeline_ms}ms${NC}"+	fi+ 	# Source and IR sizes 	local src_size 	src_size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null)