diff --git a/memory-testing/buffer.mjs b/memory-testing/buffer.mjs index deab401d..24f257f8 100644 --- a/memory-testing/buffer.mjs +++ b/memory-testing/buffer.mjs @@ -10,18 +10,18 @@ const require = createRequire(import.meta.url) const api = require(`./index.node`) let i = 1 +const FIXTURE = Buffer.allocUnsafe(1000 * 1000 * 20) // 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))) + api.bufferConvert(Buffer.from(FIXTURE)) + api.arrayBufferConvert(Uint8Array.from(FIXTURE)) + api.bufferPassThrough(Buffer.from(FIXTURE)) + api.arrayBufferPassThrough(Uint8Array.from(FIXTURE)) if (i % 10 === 0) { - await setTimeout(100) + await setTimeout(1000) + global?.gc?.() displayMemoryUsageFromNode(initialMemoryUsage) } i++ diff --git a/memory-testing/test-util.mjs b/memory-testing/test-util.mjs index d4436ded..11166c81 100644 --- a/memory-testing/test-util.mjs +++ b/memory-testing/test-util.mjs @@ -10,7 +10,7 @@ const sleep = promisify(setTimeout) const client = new Dockerode() export async function createSuite(testFile, maxMemoryUsage) { - console.info(chalk.cyanBright('Create container')) + console.info(chalk.cyanBright(`Create container to test ${testFile}`)) const container = await client.createContainer({ Image: 'node:lts-slim',