Every number comes from axle bench: run time, peak RAM at compile and run, and binary size — with the exact source for each language.
Benchmarks for v0.21.0
StringBuilder append throughput — building one large string.
| Variant | Run | Compile | Output | ||
|---|---|---|---|---|---|
| Run time | RAM | Compile time | RAM | Binary | |
| Rust -O2 | 7 ms | 44.5 MB | 104 ms | 106.5 MB | 3863 KB |
| Rust -O3 | 7 ms | 44.5 MB | 105 ms | 106.4 MB | 3863 KB |
| Rust -O1 | 8 ms | 44.5 MB | 96 ms | 104.6 MB | 3863 KB |
| Axle -O2 | 12 ms | 44.5 MB | 87 ms | 112.4 MB | 306 KB |
| Axle -O3 | 12 ms | 44.5 MB | 85 ms | 112.6 MB | 306 KB |
| Axle -O1 | 13 ms | 44.5 MB | 79 ms | 112.4 MB | 306 KB |
| Axle -O0 | 18 ms | 44.5 MB | 72 ms | 112.5 MB | 306 KB |
| C++ -O1 | 22 ms | 44.5 MB | 486 ms | 117.2 MB | 17 KB |
| C++ -O2 | 22 ms | 44.5 MB | 497 ms | 117.5 MB | 17 KB |
| C++ -O3 | 22 ms | 44.5 MB | 491 ms | 117.5 MB | 17 KB |
| Rust -O0 | 39 ms | 44.5 MB | 88 ms | 104.0 MB | 3869 KB |
| C++ -O0 | 63 ms | 44.5 MB | 467 ms | 113.7 MB | 30 KB |
// EXPECTED_EXIT: 0
// StringBuilder benchmark #1 — raw append throughput.
// Shared logic with append.cpp / append.rs
// (run via `axle bench --compare cpp,rust`).
//
// Workload: append a fixed 16-byte ASCII chunk 1,000,000 times,
// building a 16 MB buffer (~20 capacity-doubling reallocations).
// Output: total length + 3 sampled bytes (start / middle / end) so
// the three languages cross-check byte-identically without an
// O(n^2) full-string walk.
use std::text::StringBuilder;
fn main() : i32 {
let n : i64 = 1000000;
let chunk : string = "abcdefghijklmnop"; // 16 ASCII bytes
let sb : StringBuilder = new StringBuilder();
let mut i : i64 = 0;
while (i < n) {
sb.append(chunk);
i = i + 1;
}
// O(1) byte length as the cross-impl correctness signal (the
// workload is deterministic, so identical length ⇒ identical
// bytes). Reading individual bytes back via `byteAt` would be
// O(n) per call (AxleString carries no length → `strlen`), which
// would measure the string ABI, not the builder.
println(sb.byteLength());
sb.dispose();
return 0;
}StringBuilder grow / reset churn across many small builders.
| Variant | Run | Compile | Output | ||
|---|---|---|---|---|---|
| Run time | RAM | Compile time | RAM | Binary | |
| Axle -O2 | 7 ms | 44.6 MB | 100 ms | 115.1 MB | 313 KB |
| Axle -O3 | 7 ms | 44.6 MB | 103 ms | 115.0 MB | 313 KB |
| Axle -O1 | 8 ms | 44.6 MB | 89 ms | 115.0 MB | 313 KB |
| Rust -O2 | 9 ms | 44.6 MB | 117 ms | 108.6 MB | 3863 KB |
| Rust -O3 | 9 ms | 44.6 MB | 116 ms | 108.4 MB | 3863 KB |
| Rust -O1 | 11 ms | 44.6 MB | 106 ms | 107.4 MB | 3863 KB |
| C++ -O2 | 21 ms | 44.6 MB | 503 ms | 117.5 MB | 17 KB |
| C++ -O1 | 23 ms | 44.6 MB | 499 ms | 117.2 MB | 17 KB |
| C++ -O3 | 25 ms | 44.6 MB | 508 ms | 117.2 MB | 17 KB |
| Axle -O0 | 29 ms | 44.6 MB | 83 ms | 115.1 MB | 314 KB |
| Rust -O0 | 144 ms | 44.6 MB | 94 ms | 106.2 MB | 3870 KB |
| C++ -O0 | 200 ms | 44.6 MB | 478 ms | 113.8 MB | 32 KB |
// EXPECTED_EXIT: 0
// StringBuilder benchmark #3 — build / materialize / reset churn.
// Shared logic with churn.cpp / churn.rs (run via `axle bench --compare cpp,rust`).
//
// Workload: 200,000 outer rounds; each appends a 3-byte chunk 20
// times, materialises the result to a `string` (one alloc + copy),
// reads its first byte into an accumulator (so the build can't be
// optimised away), then clear()s for reuse. Stresses the
// append + toString + clear hot loop with buffer reuse. Output:
// the accumulated first-byte sum.
use std::text::StringBuilder;
fn main() : i32 {
let outer : i64 = 200000;
let inner : i64 = 20;
let chunk : string = "xyz";
let sb : StringBuilder = new StringBuilder();
let mut acc : i64 = 0;
let mut o : i64 = 0;
while (o < outer) {
let mut k : i64 = 0;
while (k < inner) {
sb.append(chunk);
k = k + 1;
}
let s : string = sb.toString();
acc = acc + (s.byteAt(0) as i64);
sb.clear();
o = o + 1;
}
println(acc);
sb.dispose();
return 0;
}Integer-to-string formatting via StringBuilder.
| Variant | Run | Compile | Output | ||
|---|---|---|---|---|---|
| Run time | RAM | Compile time | RAM | Binary | |
| Axle -O2 | 8 ms | 44.9 MB | 99 ms | 112.5 MB | 306 KB |
| Axle -O3 | 8 ms | 44.9 MB | 101 ms | 112.6 MB | 306 KB |
| Axle -O1 | 10 ms | 44.9 MB | 84 ms | 112.5 MB | 306 KB |
| C++ -O1 | 10 ms | 44.9 MB | 499 ms | 117.3 MB | 17 KB |
| C++ -O2 | 10 ms | 44.9 MB | 506 ms | 117.7 MB | 17 KB |
| C++ -O3 | 10 ms | 44.9 MB | 507 ms | 117.3 MB | 17 KB |
| Rust -O3 | 15 ms | 44.9 MB | 117 ms | 109.0 MB | 3863 KB |
| Rust -O2 | 16 ms | 44.9 MB | 118 ms | 109.2 MB | 3864 KB |
| Rust -O1 | 19 ms | 44.9 MB | 106 ms | 108.3 MB | 3863 KB |
| Axle -O0 | 20 ms | 44.9 MB | 74 ms | 112.3 MB | 307 KB |
| Rust -O0 | 64 ms | 44.9 MB | 93 ms | 106.9 MB | 3874 KB |
| C++ -O0 | 96 ms | 44.9 MB | 467 ms | 114.1 MB | 30 KB |
// EXPECTED_EXIT: 0
// StringBuilder benchmark #2 — integer formatting throughput.
// Shared logic with int_format.cpp / int_format.rs
// (run via `axle bench --compare cpp,rust`).
//
// Workload: append 500,000 LCG-driven integers (each formatted to
// decimal) separated by commas — a CSV-style builder. Stresses
// `appendI64` (int→string conversion + bulk append) plus the
// comma separator append. Output: total length + first / last byte.
//
// Caveat: `appendI64` writes the digits straight into the builder, where the
// siblings' `std::to_string` / `to_string()` materialise a temporary per
// integer. An API difference, not a language-speed one — read this bench for
// Axle's formatter, not as a like-for-like ratio.
use std::text::StringBuilder;
fn main() : i32 {
let n : i64 = 500000;
let sb : StringBuilder = new StringBuilder();
let mut seed : i64 = 12345;
let mut i : i64 = 0;
while (i < n) {
seed = (seed * 48271) % 2147483647;
sb.appendI64(seed % 100000);
sb.append(",");
i = i + 1;
}
// O(1) byte length as the cross-impl correctness signal (same
// LCG + same integer formatting ⇒ identical bytes ⇒ identical
// length). See append.axle for why per-byte readback is avoided.
println(sb.byteLength());
sb.dispose();
return 0;
}