//! Extended test (`zig build test-extended`): the interpreter's execution //! memory is bounded by live state, not by the iteration count, at full //! scale with the default collection threshold. The fast form runs in //! `zig build test` (src/interp/machine.zig). const std = @import("std"); const aji = @import("aji"); const mt = aji.interp.memory_test; test "execution memory at 100k / 1M / 4M iterations" { inline for (mt.loop_shapes, 0..) |shape, k| { const small = try mt.memoryOf(shape, 100_000, null); const mid = try mt.memoryOf(shape, 1_000_000, null); const large = try mt.memoryOf(shape, 4_000_000, null); errdefer std.debug.print("shape {d}: live {d}/{d}/{d} heap {d}/{d}/{d} collections {d}/{d}/{d}\n", .{ k, small.peak_live, mid.peak_live, large.peak_live, small.peak_heap, mid.peak_heap, large.peak_heap, small.collections, mid.collections, large.collections, }); try std.testing.expect(large.collections > 0); // Steady state: the live state of 4M iterations is the live state of 1M. try std.testing.expect(large.peak_live <= mid.peak_live + 64 * 1024); // The heap is bounded by a constant (collection threshold plus one growth step). try std.testing.expect(large.peak_heap <= 3 * mt.min_threshold); } }