aboutsummaryrefslogtreecommitdiff
path: root/docs/history/15-o3/code/bench.sh
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:09:21 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 09:09:21 +0330
commitdc7f7407e08f54e4a2a3c1d1723b2a7d6959532d (patch)
treed1de9f471a99951c57896f85b5e5523eeb96cee1 /docs/history/15-o3/code/bench.sh
parenttodo: sync docs, examples and fixtures with the include format, and test acto... (diff)
docs: archive the frozen stage code as one compressed tarball
docs/history kept six stages with a full copy of the project under code/, 3.8 mb of sources duplicated from stage to stage and already superseded. store them as docs/history/code-snapshots.tar.gz, 0.66 mb, and extract one in place to read it. every stage's notes.md stays browsable, and the index says where the code went and how to get it back. the top-level README points at the archive too. its other two links into docs/history, 21-micro and 35-bench, were notes that were never kept and do not resolve; the index now records that.
Diffstat (limited to 'docs/history/15-o3/code/bench.sh')
-rwxr-xr-xdocs/history/15-o3/code/bench.sh26
1 files changed, 0 insertions, 26 deletions
diff --git a/docs/history/15-o3/code/bench.sh b/docs/history/15-o3/code/bench.sh
deleted file mode 100755
index c5e5a83..0000000
--- a/docs/history/15-o3/code/bench.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-# o3 against plain code: each kernel in tests/bench.zc on each backend, with
-# the time to start up and compile (the 'z' run) taken off. needs bc.
-cd "$(dirname "$0")"; T=$(mktemp -d); trap 'rm -rf $T' EXIT
-gcc -O2 -w -DJTYPE=int core.c io_linux.c -o $T/zy
-vms=("$T/zy"); names=("interp")
-if command -v llvm-config >/dev/null; then
- gcc -O2 -w -DJTYPE=int -DZYLLVM $(llvm-config --cflags) core.c io_linux.c -o $T/zyl $(llvm-config --ldflags --libs) && { vms+=("$T/zyl"); names+=("llvm"); }
-fi
-if command -v aarch64-linux-gnu-gcc >/dev/null && command -v qemu-aarch64 >/dev/null; then
- aarch64-linux-gnu-gcc -O2 -w -DJTYPE=int -static core.c io_linux.c -o $T/zyj && { vms+=("qemu-aarch64 $T/zyj"); names+=("arm64 (qemu)"); }
-fi
-# seconds per run of kernel $2 on vm $1: the slope between $3 runs and 1 run,
-# best of three each, so starting up and compiling cancel out
-t(){ local s e; s=$(date +%s.%N); (cat tests/bench.zc; printf '`'$2$3) | $1 >/dev/null; e=$(date +%s.%N); echo "$e - $s" | bc; }
-best(){ local b=999 x i; for i in 1 2 3; do x=$(t "$1" $2 $3); b=$(echo "if ($x < $b) $x else $b" | bc); done; echo $b; }
-per(){ echo "scale=5; ($(best "$1" $2 $3) - $(best "$1" $2 1)) / ($3 - 1)" | bc; }
-printf "%-14s %-8s %10s %10s %8s\n" backend kernel "plain ms" "o3 ms" speedup
-for i in "${!vms[@]}"; do
- n=41; [ "${names[$i]}" = interp ] && n=5
- for k in "collatz a b" "sieve c d" "digits e f" "fib g h"; do
- set -- $k
- p=$(per "${vms[$i]}" $2 5); o=$(per "${vms[$i]}" $3 $n)
- printf "%-14s %-8s %10.2f %10.2f %7.1fx\n" "${names[$i]}" $1 $(echo "$p * 1000" | bc) $(echo "$o * 1000" | bc) $(echo "scale=2; $p / $o" | bc)
- done
-done