1 programs measured with axle bench: sort_int. Run time, peak RAM at compile and run, and binary size, with the exact source for each language.
Benchmarks for v0.23.0
Sort 2M i64 with an LSD radix sort in all three languages — Axle's stdlib ArrayList.sort() against a hand-rolled matching radix in C++ and Rust (8-bit digits, byte-skipping on the data's range). Same algorithm, so the number is a language-speed reading.
| Variant | Run | Compile | Output | ||
|---|---|---|---|---|---|
| Run time | RAM | Compile time | RAM | Binary | |
| Axle -O3 | 26 ms | 44.8 MB | 134 ms | 123.2 MB | 309 KB |
| Axle -O2 | 27 ms | 44.8 MB | 138 ms | 123.4 MB | 310 KB |
| C++ -O2 | 27 ms | 44.8 MB | 283 ms | 109.9 MB | 16 KB |
| C++ -O3 | 28 ms | 44.8 MB | 286 ms | 109.9 MB | 16 KB |
| Rust -O2 | 28 ms | 44.8 MB | 135 ms | 153.3 MB | 3864 KB |
| Rust -O3 | 28 ms | 44.8 MB | 134 ms | 151.9 MB | 3864 KB |
| Axle -O1 | 29 ms | 44.8 MB | 103 ms | 125.3 MB | 309 KB |
| Rust -O1 | 29 ms | 44.8 MB | 127 ms | 151.7 MB | 3864 KB |
| C++ -O1 | 30 ms | 44.8 MB | 274 ms | 109.2 MB | 17 KB |
| Axle -O0 | 63 ms | 44.8 MB | 80 ms | 123.4 MB | 310 KB |
| C++ -O0 | 92 ms | 44.8 MB | 253 ms | 105.6 MB | 30 KB |
| Rust -O0 | 123 ms | 44.8 MB | 103 ms | 147.5 MB | 3878 KB |
// EXPECTED_EXIT: 0
// Sort 2,000,000 i64 drawn from a shared MINSTD LCG, then print a checksum
// (full sum + the min / median / max of the sorted array). The C++ and Rust
// siblings generate the SAME data from the same seed and print the same four
// lines, so the harness cross-checks correctness.
//
// `ArrayList<i64>.sort()` dispatches on the element type at compile time
// (see `crates/5-stdlib/axle_stdlib/axle/collections/arraylist.axle`, "Sort the
// elements..."): for `i64` that is an O(n) LSD radix sort, 8-bit digits,
// skipping any byte that never varies across the key set. The C++ and Rust
// siblings hand-roll the same LSD radix sort — same digit width, same
// byte-skip via the data's max value — so all three measure the identical
// algorithm.
use std::collections::ArrayList;
fn main() : i32 {
let n : i64 = 2000000;
let l : ArrayList<i64> = new ArrayList<i64>();
l.reserve(n); // pre-size the buffer, mirroring C++ `reserve` / Rust `with_capacity`
let mut seed : i64 = 12345;
let mut i : i64 = 0;
while (i < n) {
seed = (seed * 48271) % 2147483647;
l.add(seed % 1000000);
i = i + 1;
}
l.sort();
let mut sum : i64 = 0;
i = 0;
while (i < n) {
sum = sum + (l.get(i) ?? 0);
i = i + 1;
}
println(sum);
println(l.get(0) ?? 0);
println(l.get(n / 2) ?? 0);
println(l.get(n - 1) ?? 0);
return 0;
}