3 programs measured with axle bench: append, churn, int_format. Run time, peak RAM at compile and run, and binary size, with the exact source for each language.
Benchmarks for v0.23.0
StringBuilder append throughput — building one large string.
| Variant | Run | Compile | Output | ||
|---|---|---|---|---|---|
| Run time | RAM | Compile time | RAM | Binary | |
| Rust -O2 | 5 ms | 44.8 MB | 102 ms | 146.9 MB | 3863 KB |
| Rust -O3 | 5 ms | 44.8 MB | 102 ms | 144.8 MB | 3863 KB |
| Rust -O1 | 6 ms | 44.8 MB | 95 ms | 142.3 MB | 3863 KB |
| Axle -O1 | 7 ms | 44.8 MB | 78 ms | 121.4 MB | 306 KB |
| Axle -O2 | 7 ms | 44.8 MB | 84 ms | 124.6 MB | 306 KB |
| Axle -O3 | 7 ms | 44.8 MB | 84 ms | 123.3 MB | 306 KB |
| Axle -O0 | 12 ms | 44.8 MB | 74 ms | 125.4 MB | 306 KB |
| C++ -O1 | 12 ms | 44.8 MB | 447 ms | 120.5 MB | 17 KB |
| C++ -O2 | 12 ms | 44.8 MB | 454 ms | 120.7 MB | 17 KB |
| C++ -O3 | 12 ms | 44.8 MB | 457 ms | 120.9 MB | 17 KB |
| Rust -O0 | 35 ms | 44.8 MB | 89 ms | 143.8 MB | 3869 KB |
| C++ -O0 | 51 ms | 44.8 MB | 431 ms | 116.9 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 -O1 | 8 ms | 45.1 MB | 87 ms | 127.6 MB | 315 KB |
| Rust -O2 | 9 ms | 45.1 MB | 109 ms | 145.1 MB | 3863 KB |
| Rust -O3 | 9 ms | 45.1 MB | 108 ms | 147.0 MB | 3863 KB |
| Axle -O3 | 10 ms | 45.1 MB | 97 ms | 124.2 MB | 315 KB |
| Axle -O2 | 11 ms | 45.1 MB | 95 ms | 125.4 MB | 315 KB |
| Rust -O1 | 11 ms | 45.1 MB | 101 ms | 147.5 MB | 3863 KB |
| C++ -O1 | 21 ms | 45.1 MB | 459 ms | 120.5 MB | 17 KB |
| C++ -O2 | 21 ms | 45.1 MB | 461 ms | 120.7 MB | 17 KB |
| C++ -O3 | 25 ms | 45.1 MB | 457 ms | 120.8 MB | 17 KB |
| Axle -O0 | 29 ms | 45.1 MB | 82 ms | 126.2 MB | 316 KB |
| Rust -O0 | 138 ms | 45.1 MB | 92 ms | 142.0 MB | 3870 KB |
| C++ -O0 | 192 ms | 45.1 MB | 437 ms | 117.1 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 | 45.9 MB | 97 ms | 123.4 MB | 306 KB |
| Axle -O3 | 8 ms | 45.9 MB | 98 ms | 123.0 MB | 306 KB |
| Axle -O1 | 9 ms | 45.9 MB | 83 ms | 123.5 MB | 306 KB |
| C++ -O1 | 9 ms | 45.9 MB | 467 ms | 120.6 MB | 17 KB |
| C++ -O2 | 9 ms | 45.9 MB | 469 ms | 121.0 MB | 17 KB |
| C++ -O3 | 9 ms | 45.9 MB | 472 ms | 120.9 MB | 17 KB |
| Rust -O2 | 15 ms | 45.9 MB | 114 ms | 146.0 MB | 3864 KB |
| Rust -O3 | 15 ms | 45.9 MB | 114 ms | 147.8 MB | 3863 KB |
| Rust -O1 | 18 ms | 45.9 MB | 103 ms | 148.7 MB | 3863 KB |
| Axle -O0 | 19 ms | 45.9 MB | 74 ms | 125.4 MB | 307 KB |
| Rust -O0 | 59 ms | 45.9 MB | 93 ms | 144.1 MB | 3874 KB |
| C++ -O0 | 91 ms | 45.9 MB | 436 ms | 117.4 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;
}