ref: 91a715bcdfdd2c762c700b45591e74f42c4a0626
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 ;; }