test(memory-testing): adjust buffer tests
This commit is contained in:
parent
c76be2f1e0
commit
6ff69a1dab
2 changed files with 8 additions and 8 deletions
|
@ -10,18 +10,18 @@ const require = createRequire(import.meta.url)
|
||||||
const api = require(`./index.node`)
|
const api = require(`./index.node`)
|
||||||
|
|
||||||
let i = 1
|
let i = 1
|
||||||
|
const FIXTURE = Buffer.allocUnsafe(1000 * 1000 * 20)
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
api.bufferLen()
|
api.bufferLen()
|
||||||
api.arrayBufferLen()
|
api.arrayBufferLen()
|
||||||
api.bufferConvert(Buffer.from(Array.from({ length: 1024 * 10240 }).fill(1)))
|
api.bufferConvert(Buffer.from(FIXTURE))
|
||||||
api.arrayBufferConvert(
|
api.arrayBufferConvert(Uint8Array.from(FIXTURE))
|
||||||
Uint8Array.from(Array.from({ length: 1024 * 10240 }).fill(1)),
|
api.bufferPassThrough(Buffer.from(FIXTURE))
|
||||||
)
|
api.arrayBufferPassThrough(Uint8Array.from(FIXTURE))
|
||||||
api.bufferPassThrough(Buffer.from('hello world'.repeat(1024 * 1024)))
|
|
||||||
api.arrayBufferPassThrough(Uint8Array.from('hello world'.repeat(1024 * 1024)))
|
|
||||||
if (i % 10 === 0) {
|
if (i % 10 === 0) {
|
||||||
await setTimeout(100)
|
await setTimeout(1000)
|
||||||
|
global?.gc?.()
|
||||||
displayMemoryUsageFromNode(initialMemoryUsage)
|
displayMemoryUsageFromNode(initialMemoryUsage)
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
|
|
|
@ -10,7 +10,7 @@ const sleep = promisify(setTimeout)
|
||||||
const client = new Dockerode()
|
const client = new Dockerode()
|
||||||
|
|
||||||
export async function createSuite(testFile, maxMemoryUsage) {
|
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({
|
const container = await client.createContainer({
|
||||||
Image: 'node:lts-slim',
|
Image: 'node:lts-slim',
|
||||||
|
|
Loading…
Reference in a new issue