# Radlang overview benchmarks Two runnable suites that place radlang next to mainstream languages and web stacks on one machine. Both verify every output before timing it, alternate runs across languages, and report the best of N. ``` benchmarks/overview/cpu-suite.py [--radlang radlang] [--runs 3] [--timeout 60] [--only n-body,fasta] [--skip python] benchmarks/overview/web-suite.py [--radlang radlang] [--db sqlite|mysql] [--runs 3] [--seconds 5] [--connections 32] [--skip go,rust] [--only db,fortunes] ``` `--radlang` takes a compiler binary, optionally `:`; `--node` and `--bun` choose those runtimes. A toolchain missing from PATH is skipped. Run on an idle host. ## CPU suite (`cpu/`) Six Benchmarks Game programs, each written once per language with the same single-threaded algorithm (not the tuned, multi-core Benchmarks Game entries): | Program | Size | Exercises | | --- | --- | --- | | binary-trees | depth 18 | allocation of short-lived recursive structs | | fannkuch-redux | 10 | integer list indexing and in-place swaps | | n-body | 5,000,000 steps | float arithmetic over small lists | | spectral-norm | 3000 | nested float loops, function calls | | mandelbrot | 4000 | tight scalar float loop (reports the in-set count) | | fasta | 2,500,000 | string slicing, byte lists, stdout throughput | Ports: radlang, C (`cc -O2`), Rust (`rustc -C opt-level=3`), Go, Node and Bun (one `.js` file), Python, and C#/.NET 10 (`dotnet build -c Release`, managed JIT). Output is checked against the first language's digest (n-body and spectral-norm to nine decimals). The report gives wall time, radlang's speed relative to each language (above 1x is faster), peak RSS, and total build time. ## Web suite (`http/`) TechEmpower-style test types on `127.0.0.1:18080`: | Test | Route | Work | | --- | --- | --- | | plaintext | `/plaintext` | fixed text body | | json | `/json` | serialize `{"message": "Hello, World!"}` | | db | `/db` | one random `world` row by id, as JSON | | queries | `/queries?queries=20` | 20 separate row reads, as a JSON list | | fortunes | `/fortunes` | read 12 rows, add one, sort, render an escaped HTML table | Servers, each held to one core's worth of request handling: | Server | Stack | | --- | --- | | radlang | `server.rad`, `RAD_HTTP_WORKERS=1`, async SQLite reads | | node | `server.node.js`: `node:http`, `node:sqlite` | | bun | `bun/server.js`: Hono on `Bun.serve`, `bun:sqlite` | | go | `go/`: `net/http`, `mattn/go-sqlite3`, `html/template`, `GOMAXPROCS=1` | | rust | `rust/`: axum on a current-thread tokio runtime, `rusqlite` | | dotnet | `dotnet/`: ASP.NET Core/Kestrel minimal endpoints, native SQLite prepared statements | The suite seeds one SQLite file (10,000 `world` rows, the 12 standard fortunes), starts each server in turn, checks every route's body (row values, fortune order and escaping), then loads each route with `wrk -t2 -c32 --latency`. It reports requests/s, p99 latency, the CPU cores each server used under load (radlang runs SQLite on a worker thread, so it can exceed 1.0), and peak RSS. Setup: `wrk`; `bun install` in `http/bun` (the suite runs it when Hono is missing); Go and Cargo fetch their modules on first build. ## MySQL mode `web-suite.py --db mysql` runs the same five routes against a local MySQL server instead of SQLite. Setup: MySQL on `127.0.0.1:3306` with database, user and password all `bench` (the user needs rights on the database). The suite drops, recreates and reseeds `world` and `fortune` through the `mysql` CLI on every run, so the data matches the SQLite suite. ``` BENCH_DB_CONNS=1 web-suite.py --db mysql --runs 1 --seconds 5 ``` Every server gets `BENCH_DB_URL=mysql://bench:bench@127.0.0.1:3306/bench` and a pool of `BENCH_DB_CONNS` connections (default 1). One connection is the fair default: radlang holds one connection per `Database`, as the SQLite suite holds one. Set `BENCH_DB_CONNS=8` to see what a pool buys the others; radlang ignores it. | Server | Driver | | --- | --- | | radlang | `server.rad` (reads `BENCH_DB_URL`, else `BENCH_DB` as SQLite) | | node | `server.node.mysql.js`: `mysql2` promise API, `execute` (prepared) | | bun | `bun/server.mysql.js`: Hono, `mysql2` | | go | `go/main.go` (same file): `go-sql-driver/mysql`, `database/sql` prepared statements | | rust | `rust/src/mysql.rs`: axum, `mysql_async` (cached prepared statements) | | dotnet | `dotnet/mysql/`: `MySqlConnector`, prepared commands, `ConnectionReset=false` | radlang loads the MySQL client library at run time, so `server.rad` builds the same way in both modes. Install the drivers with `npm install` in `http/` and `bun install` in `http/bun` (the suite installs the Bun one when missing). ## Notes - Node and Bun use synchronous SQLite calls, Go blocks a goroutine, Rust holds a mutex on one connection; radlang awaits its DB futures. - `server.rad` is written the way an application would be: inline async handlers capturing the connection, and fortunes added to and sorted as `DbFortune` rows. Before 1.28.6 both shapes pinned each request's task arena until the keep-alive connection closed (gigabytes under wrk). ## C#/.NET only Requires the .NET 10 SDK; no NuGet package dependencies. CPU ports use the same single-threaded algorithms and sizes, with ordinary managed objects/arrays. Release builds use the standard JIT, not Native AOT; process startup/JIT is part of CPU elapsed time, just as for Node/Bun/Python. `DOTNET_PROCESSOR_COUNT=1` is set for .NET benchmark processes (not a hard OS affinity constraint). ``` python3 benchmarks/overview/cpu-suite.py --include dotnet --runs 3 --expected-digests /path/to/digests.json --json /tmp/dotnet-cpu.json python3 benchmarks/overview/web-suite.py --include dotnet --runs 3 --seconds 5 --connections 32 --json /tmp/dotnet-web.json ``` `--include` filters toolchains before building or running. `--expected-digests` is a JSON object mapping each workload name to its previously verified stdout MD5; use it to validate a new-language-only CPU run without repeating the other languages. Without it, CPU output is compared with the first selected language, as in the original suite. `--json` saves all individual samples and versions. The HTTP port uses [Kestrel](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-10.0) with JSON serialization, the same SQLite file, prepared queries, and escaped fortune HTML. One connection is protected by a lock, like the Rust mutex design. It uses the system SQLite library via P/Invoke (`sqlite3` must be discoverable), not an ORM or response cache. Measured CPU use remains part of the report. The CPU runner now enforces its timeout while a process is silent; formerly a blocking stdout read could postpone enforcement. Output is captured in a temporary file and digested after the timed process exits. HTTP remains the same three-round, per-process route-check and load procedure by default. ## End-to-end application workloads See [application benchmarks](../application/README.md) for typed JSON pipelines, concurrent outbound requests, streaming file processing, WebSocket fan-out and a bounded long-lived cache workload across the six service stacks.