slovo/benchmarks/string-eq-loop
2026-05-22 08:38:43 +02:00
..
c Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
clojure Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
common-lisp Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
python Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
rust Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
src Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
.gitignore Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
benchmark.json Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
README.md Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
run.py Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00
slovo.toml Import Slovo 1.0.0-beta monorepo 2026-05-22 08:38:43 +02:00

String Equality Loop Benchmark Scaffold

Release: exp-119.

This benchmark compares exact ASCII string content equality plus i32 checksum accumulation across Slovo, C, Rust, Python, Clojure, and Common Lisp/SBCL on the same machine.

It is not a published benchmark result, performance threshold, optimizer claim, or cross-machine comparison.

Files

  • src/main.slo: Slovo project benchmark fixture
  • c/string_eq_loop.c: C comparison implementation
  • rust/string_eq_loop.rs: Rust comparison implementation
  • python/string_eq_loop.py: Python comparison implementation
  • clojure/string_eq_loop.clj: Clojure comparison implementation
  • common-lisp/string_eq_loop.lisp: Common Lisp/SBCL comparison implementation
  • run.py: build/run/timing harness

All implementations print checksum 4600001 for loop count 1000000 and target string omega. Hot-loop mode uses loop count 10000000 and checksum 46000001. The runner supplies the loop count and target string at runtime.

Commands

Run from the Glagol repository root:

python3 benchmarks/string-eq-loop/run.py --list
python3 benchmarks/string-eq-loop/run.py --dry-run
python3 benchmarks/string-eq-loop/run.py --only python --repeats 3 --warmups 1
python3 benchmarks/string-eq-loop/run.py --mode hot-loop --only slovo --only c --only rust

To include Slovo, build or point at a Glagol binary and make sure host Clang is available:

cargo build --manifest-path compiler/Cargo.toml --bin glagol
python3 benchmarks/string-eq-loop/run.py --glagol compiler/target/debug/glagol

The runner skips missing C/Rust/Slovo/Clojure/SBCL toolchains where possible. Use --only multiple times to select implementations:

python3 benchmarks/string-eq-loop/run.py --only slovo --only c --only rust --only clojure --only common_lisp

Clojure is detected with clojure on PATH, CLOJURE, or CLOJURE_JAR. Common Lisp is detected with sbcl on PATH, SBCL, or --sbcl.

Comparison Method

  • The runner builds each implementation once before timing. The reported numbers measure execution only, not compile time.
  • Slovo timings use glagol build, which currently lowers to LLVM and then invokes host clang -O2 with runtime/runtime.c.
  • C timings use clang -O2 -std=c11.
  • Rust timings use rustc -C opt-level=3 -C debuginfo=0.
  • The measured loop keeps one fixed immutable string array in local scope, indexes it with a loop-carried % 5 position, and compares the selected string against a runtime-supplied ASCII target by content equality only.

Timing is cold-process local-machine evidence only. Clojure timings include JVM and Clojure startup, while Common Lisp timings include SBCL script startup.

Hot-loop mode is startup-amortized local evidence. It runs a larger loop count and reports total time plus normalized time for the base 1000000 loop count.