bench/run.sh was Janet-era: it invoked a 'jolt' binary and set JOLT_DIRECT_LINK/JOLT_WHOLE_PROGRAM, none of which exist on Chez, where 'joltc run -m' runs fully unoptimized (direct-link and inline default off). So the suite was measuring jolt's unoptimized path. run.sh now compiles each benchmark to an optimized AOT binary (joltc build --direct-link --opt) and times it against JVM Clojure on the same portable source, auto-detecting the Chez kernel dev files like build-smoke.sh. Adds bench/deps.edn so joltc resolves the namespaces, NO_JVM to skip the reference. mandelbrot.clj dropped its jolt.png require so the JVM reference can run it; the picture demo moved to mandelbrot_png.clj (jolt-only). README scorecard refreshed with current Chez numbers and the two-regime read (compute ~8-10x substrate floor; dispatch/alloc ~120-330x architectural gaps the passes don't touch). Stale 'jolt -m' header lines point at bench/run.sh. Co-authored-by: Yogthos <yogthos@gmail.com>
29 lines
1.1 KiB
Clojure
29 lines
1.1 KiB
Clojure
;; fib — naive recursive Fibonacci: pure function-call + integer-arithmetic
|
|
;; throughput, with no allocation, dispatch, or collections. Isolates call
|
|
;; overhead and native integer arith, and is the natural target for
|
|
;; single-call-site / small-fn inlining and self-call direct-linking.
|
|
;;
|
|
;; Portable Clojure (jolt + JVM Clojure).
|
|
;; bench/run.sh fib 32
|
|
(ns fib)
|
|
|
|
(defn fib [n]
|
|
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
|
|
|
|
(defn run [n] (fib n))
|
|
|
|
(defn -main [& args]
|
|
(let [n (if (seq args) (Integer/parseInt (first args)) 32)]
|
|
(dotimes [_ 2] (run (- n 6))) ; warmup
|
|
(let [runs 3
|
|
times (mapv (fn [_]
|
|
(let [t0 (System/nanoTime)
|
|
r (run n)
|
|
ms (/ (- (System/nanoTime) t0) 1000000.0)]
|
|
[ms r]))
|
|
(range runs))
|
|
mss (mapv first times)
|
|
mean (/ (reduce + mss) runs)]
|
|
(println "fib n" n "result" (second (first times)))
|
|
(println "runs:" (mapv (fn [t] (/ (Math/round (* t 10.0)) 10.0)) mss))
|
|
(println "mean:" (/ (Math/round (* mean 10.0)) 10.0) "ms"))))
|