Files
node/benchmark/napi/make_callback/index.js
T
Nigro Simone e77e173004 benchmark: add a node::MakeCallback benchmark
The addon calls into JS with node::MakeCallback from a libuv timer, so
every call opens a top-level callback scope, like an I/O callback does.

Signed-off-by: Nigro Simone <nigro.simone@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66316
Refs: https://github.com/nodejs/performance/issues/24
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-29 06:45:36 +00:00

24 lines
548 B
JavaScript

'use strict';
const common = require('../../common.js');
// The addon calls into JS with node::MakeCallback from a libuv timer, so
// every call opens a top-level callback scope, like an I/O callback does.
let binding;
try {
binding = require(`./build/${common.buildType}/binding`);
} catch {
console.error('napi/make_callback/index.js Binding failed to load');
process.exit(0);
}
const bench = common.createBenchmark(main, {
n: [1e6, 1e7],
});
function main({ n }) {
bench.start();
binding.run(n, () => {}, () => bench.end(n));
}