2022-07-10 01:16:44 +09:00
|
|
|
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
|
2022-10-02 13:23:35 +09:00
|
|
|
const FIXTURE = Buffer.allocUnsafe(1000 * 1000 * 20)
|
2022-07-10 01:16:44 +09:00
|
|
|
// eslint-disable-next-line no-constant-condition
|
|
|
|
while (true) {
|
|
|
|
api.bufferLen()
|
|
|
|
api.arrayBufferLen()
|
2022-10-02 13:23:35 +09:00
|
|
|
api.bufferConvert(Buffer.from(FIXTURE))
|
|
|
|
api.arrayBufferConvert(Uint8Array.from(FIXTURE))
|
2023-01-09 15:47:36 +09:00
|
|
|
api.arrayBufferCreateFromVecWithSpareCapacity()
|
2022-10-02 13:23:35 +09:00
|
|
|
api.bufferPassThrough(Buffer.from(FIXTURE))
|
|
|
|
api.arrayBufferPassThrough(Uint8Array.from(FIXTURE))
|
2022-07-10 01:16:44 +09:00
|
|
|
if (i % 10 === 0) {
|
2022-10-02 13:23:35 +09:00
|
|
|
await setTimeout(1000)
|
|
|
|
global?.gc?.()
|
2022-07-10 01:16:44 +09:00
|
|
|
displayMemoryUsageFromNode(initialMemoryUsage)
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
}
|