napi-rs/memory-testing/tokio-future.mjs
2022-04-13 13:24:53 +08:00

26 lines
527 B
JavaScript

import { createRequire } from 'module'
import { displayMemoryUsageFromNode } from './util.mjs'
const initialMemoryUsage = process.memoryUsage()
const require = createRequire(import.meta.url)
const api = require(`./index.node`)
async function main() {
let i = 1
// eslint-disable-next-line no-constant-condition
while (true) {
await api.testAsync()
if (i % 100000 === 0) {
displayMemoryUsageFromNode(initialMemoryUsage)
}
i++
}
}
main().catch((e) => {
console.error(e)
process.exit(1)
})