node/benchmark/napi/buffer/index.js
Chengzhong Wu d64835f97e
node-api: add external buffer creation benchmark
Add a micro benchmark for external buffer creation.

PR-URL: https://github.com/nodejs/node/pull/54877
Refs: https://github.com/nodejs/node/issues/53804
Refs: https://github.com/nodejs/node/issues/44111
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2024-09-14 00:29:22 +00:00

15 lines
338 B
JavaScript

'use strict';
const common = require('../../common.js');
const bench = common.createBenchmark(main, {
n: [5e6],
addon: ['binding', 'binding_node_api_v8'],
implem: ['createExternalBuffer'],
});
function main({ n, implem, addon }) {
const binding = require(`./build/${common.buildType}/${addon}`);
binding[implem](bench, n);
}