mirror of
https://github.com/nodejs/node.git
synced 2026-11-15 10:36:53 -05:00
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>
24 lines
548 B
JavaScript
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));
|
|
}
|