Page MenuHomePhorge

test_gc_async.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

test_gc_async.js

// Async GC stress: coroutine-heavy allocation without timers
function stripAnsi(str) {
return str.replace(/\x1b\[[0-9;]*m/g, '');
}
function pad(str, len) {
const visible = stripAnsi(str).length;
const diff = len - visible;
if (diff <= 0) return str;
return str + ' '.repeat(diff);
}
function render() {
const width = 120;
const height = 40;
const lines = [];
for (let y = 0; y < height; y++) {
lines.push(' '.repeat(width));
}
for (let y = 0; y < height; y++) {
let text = `\x1b[38;5;196mRow ${y}\x1b[0m: `;
text += `\x1b[38;5;82m${'█'.repeat(20)}\x1b[0m`;
text += `\x1b[2m${'░'.repeat(20)}\x1b[0m`;
text = pad(text, width);
lines[y] = text;
}
return lines.join('\n');
}
async function handleEvent(n) {
for (let i = 0; i < 10; i++) {
render();
}
}
for (let count = 1; count <= 500; count++) {
handleEvent(count);
const stats = Ant.stats();
console.log(
`tick ${count}: arena ${(stats.arenaUsed / 1024 / 1024).toFixed(1)}MB / ` +
`${(stats.arenaSize / 1024 / 1024).toFixed(1)}MB, ` +
`rss ${(stats.rss / 1024 / 1024).toFixed(1)}MB`
);
}
console.log('Done - forcing GC...');
Ant.gc();
const after = Ant.stats();
console.log(`after GC: arena ${(after.arenaUsed / 1024 / 1024).toFixed(1)}MB`);

File Metadata

Mime Type
text/plain
Expires
Wed, Jun 17, 1:25 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
558943
Default Alt Text
test_gc_async.js (1 KB)

Event Timeline