node/benchmark/napi/define_properties/index.js
Gabriel Schulhof 3c35cd4a74 node-api: provide napi_define_properties fast path
Implement defining properties via V8's
`v8::Object::CreateDataProperty()`, which is faster for data-valued,
writable, configurable, and enumerable properties.

Re: https://github.com/nodejs/node/issues/45905
Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/48440
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-06-15 18:07:30 -07:00

16 lines
357 B
JavaScript

'use strict';
const common = require('../../common.js');
const binding = require(`./build/${common.buildType}/binding`);
const bench = common.createBenchmark(main, {
n: [5e6],
implem: ['runFastPath', 'runSlowPath'],
});
function main({ n, implem }) {
const objs = Array(n).fill(null).map((item) => new Object());
binding[implem](bench, objs);
}