Benchmarks

Measured against the languages you'd compare to.

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

Strings

append

StringBuilder append throughput — building one large string.

VariantRunCompileOutput
Run timeRAMCompile timeRAMBinary
Rust -O27 ms44.5 MB104 ms106.5 MB3863 KB
Rust -O37 ms44.5 MB105 ms106.4 MB3863 KB
Rust -O18 ms44.5 MB96 ms104.6 MB3863 KB
Axle -O212 ms44.5 MB87 ms112.4 MB306 KB
Axle -O312 ms44.5 MB85 ms112.6 MB306 KB
Axle -O113 ms44.5 MB79 ms112.4 MB306 KB
Axle -O018 ms44.5 MB72 ms112.5 MB306 KB
C++ -O122 ms44.5 MB486 ms117.2 MB17 KB
C++ -O222 ms44.5 MB497 ms117.5 MB17 KB
C++ -O322 ms44.5 MB491 ms117.5 MB17 KB
Rust -O039 ms44.5 MB88 ms104.0 MB3869 KB
C++ -O063 ms44.5 MB467 ms113.7 MB30 KB
▸ Source
// 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;
}

churn

StringBuilder grow / reset churn across many small builders.

VariantRunCompileOutput
Run timeRAMCompile timeRAMBinary
Axle -O27 ms44.6 MB100 ms115.1 MB313 KB
Axle -O37 ms44.6 MB103 ms115.0 MB313 KB
Axle -O18 ms44.6 MB89 ms115.0 MB313 KB
Rust -O29 ms44.6 MB117 ms108.6 MB3863 KB
Rust -O39 ms44.6 MB116 ms108.4 MB3863 KB
Rust -O111 ms44.6 MB106 ms107.4 MB3863 KB
C++ -O221 ms44.6 MB503 ms117.5 MB17 KB
C++ -O123 ms44.6 MB499 ms117.2 MB17 KB
C++ -O325 ms44.6 MB508 ms117.2 MB17 KB
Axle -O029 ms44.6 MB83 ms115.1 MB314 KB
Rust -O0144 ms44.6 MB94 ms106.2 MB3870 KB
C++ -O0200 ms44.6 MB478 ms113.8 MB32 KB
▸ Source
// 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;
}

int_format

Integer-to-string formatting via StringBuilder.

VariantRunCompileOutput
Run timeRAMCompile timeRAMBinary
Axle -O28 ms44.9 MB99 ms112.5 MB306 KB
Axle -O38 ms44.9 MB101 ms112.6 MB306 KB
Axle -O110 ms44.9 MB84 ms112.5 MB306 KB
C++ -O110 ms44.9 MB499 ms117.3 MB17 KB
C++ -O210 ms44.9 MB506 ms117.7 MB17 KB
C++ -O310 ms44.9 MB507 ms117.3 MB17 KB
Rust -O315 ms44.9 MB117 ms109.0 MB3863 KB
Rust -O216 ms44.9 MB118 ms109.2 MB3864 KB
Rust -O119 ms44.9 MB106 ms108.3 MB3863 KB
Axle -O020 ms44.9 MB74 ms112.3 MB307 KB
Rust -O064 ms44.9 MB93 ms106.9 MB3874 KB
C++ -O096 ms44.9 MB467 ms114.1 MB30 KB
▸ Source
// 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;
}