ref: 0b0fb103248ec7b12b3a2b94d88b1fe7a0b4403e
dir: /bench/copious-allocs.myr/
use std type blob = struct x : int[10] ;; const main = { var a : blob#[10000] for var j = 0; j < 100; j++ /* alloc forwards, dealloc forwards */ for var i = 0; i < a.len; i++ a[i] = std.alloc() ;; for var i = 0; i < a.len; i++ std.free(a[i]) ;; /* alloc forwards, dealloc backwards */ for var i = 0; i < a.len; i++ a[i] = std.alloc() ;; for var i = a.len; i > 0; i-- std.free(a[i - 1]) ;; /* alloc forwards, dealloc randomly */ for var i = 0; i < a.len; i++ a[i] = std.alloc() ;; shuffle(a[:]) for var i = a.len; i > 0; i-- std.free(a[i - 1]) ;; ;; } const shuffle = {a var t var rng var j /* we want determinism for benchmarking */ rng = std.mksrng(123) for var i = 0; i < a.len - 1; i++ j = std.rngrand(rng, i, a.len) t = a[j] a[j] = a[i] a[i] = t ;; }