import { createRequire } from 'module' import { setTimeout } from 'timers/promises' import { displayMemoryUsageFromNode } from './util.mjs' const initialMemoryUsage = process.memoryUsage() const require = createRequire(import.meta.url) const api = require(`./index.node`) let i = 1 // eslint-disable-next-line no-constant-condition while (true) { api.bufferLen() api.arrayBufferLen() api.bufferConvert(Buffer.from(Array.from({ length: 1024 * 10240 }).fill(1))) api.arrayBufferConvert( Uint8Array.from(Array.from({ length: 1024 * 10240 }).fill(1)), ) api.bufferPassThrough(Buffer.from('hello world'.repeat(1024 * 1024))) api.arrayBufferPassThrough(Uint8Array.from('hello world'.repeat(1024 * 1024))) if (i % 10 === 0) { await setTimeout(100) displayMemoryUsageFromNode(initialMemoryUsage) } i++ }