ref: 97602e57fcd2bba52c50454f15cf07a97adf7342
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 ;; }