lumbda/friction.sh
russell@unturf.com f7352b51b0 rename: uncommonlisp -> lumbda throughout the repo
Historical internal name "uncommonlisp" retired in favor of the
public name "lumbda" ahead of lumbda.com going live. Scope of
this commit:

Source files renamed:
  uncommonlisp.py                     -> lumbda.py
  asm/uncommonlisp.s                  -> asm/lumbda.s
  c/uncommonlisp.h                    -> c/lumbda.h
  whitepaper/uncommonlisp-whitepaper  -> whitepaper/lumbda-whitepaper (.rst + .pdf)

Binaries renamed (tracked ones; c/ was always gitignored):
  asm/uncommonlisp, asm/uncommonlisp-gc, asm/uncommonlisp.o,
  asm/uncommonlisp-gc.o                -> asm/lumbda(-gc)(.o)
  c/.gitignore                          -> ignores lumbda

Internal string updates (sed pass ordered longest-first):
  asm/uncommonlisp -> asm/lumbda
  c/uncommonlisp   -> c/lumbda
  uncommonlisp.py  -> lumbda.py
  UNCOMMONLISP_BIN -> LUMBDA_BIN (asm/test.sh env var)
  "uncommonlisp> " -> "lumbda> " (asm REPL prompt baked into binary)
  UNCOMMONLISP     -> LUMBDA (macros, comments)
  uncommonlisp     -> lumbda (prose)

Binary portal magic updated:
  "ULPORTAL" -> "LUMBDAB1"   # "Lumbda Binary v1"
Old portal files are not backward-compatible — this is a deliberate
break since it's the rename moment. S-expression portals already
carry their own ";; lumbda-portal v1" header and remain cleanly
versioned.

WHITEPAPER.pdf / WHITEPAPER.rst symlinks repointed to the renamed
files. Makefile's whitepaper target targets lumbda-whitepaper.pdf.

Not changed (intentional, separate phases):
  - Filesystem directory /home/fox/git/uncommonlisp itself
    (fox renames locally and the gitlab repo URL in a follow-up)
  - tests.py hardcoded cwd=/home/fox/git/uncommonlisp
    (matches the current on-disk location; will flip when the
    directory rename ships)
  - Git history (immutable; old commits still say uncommonlisp,
    which is correct — that's what they were)

Verified:
  137 asm no-GC + 137 asm GC + 571 Python + 83 C + 189 shared
  functional tests all pass under the new names.
  bench-gc-http (2000 req): all 4 cells behave as expected
  (cells 1/2 flat, 3 leaks, 4 bounded at 1 chunk).
  Python REPL, C REPL, asm REPL all start cleanly.
2026-04-19 10:20:11 -04:00

127 lines
5.1 KiB
Bash

#!/bin/bash
# friction.sh — Head-to-head benchmark: CPython vs lumbda-Python vs lumbda-C
#
# Usage: bash friction.sh
set -e
cd "$(dirname "$0")"
echo "═══════════════════════════════════════════════════════════════"
echo "Friction Benchmark: CPython vs lumbda-Python vs lumbda-C"
echo "═══════════════════════════════════════════════════════════════"
echo
# Build C version
make -C c all -s 2>/dev/null
# ── fib(35) iterative ──────────────────────────────────────────
echo ">>> fib(35) iterative"
printf " CPython: "
python3 -c "
import time
def fib(n):
a, b = 0, 1
for _ in range(n): a, b = b, a+b
return a
t=time.perf_counter(); r=fib(35); print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-Python: "
python3 -c "
import time; from lumbda import *
g=make_global_env(); [leval(e,g) for e in read_all(PRELUDE)]
[leval(e,g) for e in read_all('(auto-compile! #t)')]
[leval(e,g) for e in read_all('(define (fib n) (let loop ((a 0) (b 1) (i 0)) (if (= i n) a (loop b (+ a b) (+ i 1)))))')]
t=time.perf_counter(); r=[leval(e,g) for e in read_all('(fib 35)')][-1]
print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-C: "
/usr/bin/time -f "%e s" ./c/lumbda -e '(define (fib n) (let loop ((a 0) (b 1) (i 0)) (if (= i n) a (loop b (+ a b) (+ i 1))))) (display (fib 35)) (newline)' 2>&1
echo
# ── fib(20) tree-recursive ──────────────────────────────────────
echo ">>> fib(20) tree-recursive"
printf " CPython: "
python3 -c "
import time
def fib(n):
if n <= 1: return n
return fib(n-1) + fib(n-2)
t=time.perf_counter(); r=fib(20); print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-Python: "
python3 -c "
import time,sys; sys.setrecursionlimit(50000); from lumbda import *
g=make_global_env(); [leval(e,g) for e in read_all(PRELUDE)]
[leval(e,g) for e in read_all('(auto-compile! #t)')]
[leval(e,g) for e in read_all('(define (fib n) (if (<= n 1) n (+ (fib (- n 1)) (fib (- n 2)))))')]
t=time.perf_counter(); r=[leval(e,g) for e in read_all('(fib 20)')][-1]
print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-C: "
/usr/bin/time -f "%e s" ./c/lumbda -e '(define (fib n) (if (<= n 1) n (+ (fib (- n 1)) (fib (- n 2))))) (display (fib 20)) (newline)' 2>&1
echo
# ── ackermann(3,4) ──────────────────────────────────────────────
echo ">>> ackermann(3,4)"
printf " CPython: "
python3 -c "
import time,sys; sys.setrecursionlimit(50000)
def ack(m,n):
if m==0: return n+1
if n==0: return ack(m-1,1)
return ack(m-1, ack(m, n-1))
t=time.perf_counter(); r=ack(3,4); print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-Python: "
python3 -c "
import time,sys; sys.setrecursionlimit(50000); from lumbda import *
g=make_global_env(); [leval(e,g) for e in read_all(PRELUDE)]
[leval(e,g) for e in read_all('(auto-compile! #t)')]
[leval(e,g) for e in read_all('(define (ack m n) (cond ((= m 0) (+ n 1)) ((= n 0) (ack (- m 1) 1)) (else (ack (- m 1) (ack m (- n 1))))))')]
t=time.perf_counter(); r=[leval(e,g) for e in read_all('(ack 3 4)')][-1]
print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-C: "
/usr/bin/time -f "%e s" ./c/lumbda -e '(define (ack m n) (cond ((= m 0) (+ n 1)) ((= n 0) (ack (- m 1) 1)) (else (ack (- m 1) (ack m (- n 1)))))) (display (ack 3 4)) (newline)' 2>&1
echo
# ── sum-to(50000) tail-recursive ────────────────────────────────
echo ">>> sum-to(50000) tail-recursive"
printf " CPython: "
python3 -c "
import time
def s(n):
acc=0
while n>0: acc+=n; n-=1
return acc
t=time.perf_counter(); r=s(50000); print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-Python: "
python3 -c "
import time; from lumbda import *
g=make_global_env(); [leval(e,g) for e in read_all(PRELUDE)]
[leval(e,g) for e in read_all('(auto-compile! #t)')]
[leval(e,g) for e in read_all('(define (sum-to n) (let loop ((i n) (acc 0)) (if (= i 0) acc (loop (- i 1) (+ acc i)))))')]
t=time.perf_counter(); r=[leval(e,g) for e in read_all('(sum-to 50000)')][-1]
print(f'{(time.perf_counter()-t)*1000:.3f}ms result={r}')
"
printf " lumbda-C: "
/usr/bin/time -f "%e s" ./c/lumbda -e '(define (sum-to n) (let loop ((i n) (acc 0)) (if (= i 0) acc (loop (- i 1) (+ acc i))))) (display (sum-to 50000)) (newline)' 2>&1
echo
echo "═══════════════════════════════════════════════════════════════"