benchmark: (util/v8/vm) use destructuring
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
5dfb93d2fa
commit
7a24b1c565
@ -47,11 +47,9 @@ function getInput(input) {
|
||||
}
|
||||
}
|
||||
|
||||
function main(conf) {
|
||||
const normalizeEncoding = require('internal/util').normalizeEncoding;
|
||||
|
||||
const n = conf.n | 0;
|
||||
const inputs = getInput(conf.input);
|
||||
function main({ input, n }) {
|
||||
const { normalizeEncoding } = require('internal/util');
|
||||
const inputs = getInput(input);
|
||||
var noDead = '';
|
||||
|
||||
bench.start();
|
||||
|
@ -34,16 +34,15 @@ const bench = common.createBenchmark(main, {
|
||||
flags: ['--expose-internals']
|
||||
});
|
||||
|
||||
function main(conf) {
|
||||
function main({ type, argument, version, n }) {
|
||||
// For testing, if supplied with an empty type, default to ArrayBufferView.
|
||||
conf.type = conf.type || 'ArrayBufferView';
|
||||
type = type || 'ArrayBufferView';
|
||||
|
||||
const util = process.binding('util');
|
||||
const types = require('internal/util/types');
|
||||
|
||||
const n = (+conf.n) | 0;
|
||||
const func = { native: util, js: types }[conf.version][`is${conf.type}`];
|
||||
const arg = args[conf.type][conf.argument];
|
||||
const func = { native: util, js: types }[version][`is${type}`];
|
||||
const arg = args[type][argument];
|
||||
|
||||
bench.start();
|
||||
for (var i = 0; i < n; i++) {
|
||||
|
@ -11,9 +11,7 @@ const bench = common.createBenchmark(main, {
|
||||
n: [1e6]
|
||||
});
|
||||
|
||||
function main(conf) {
|
||||
const n = +conf.n;
|
||||
const method = conf.method;
|
||||
function main({ method, n }) {
|
||||
var i = 0;
|
||||
bench.start();
|
||||
for (; i < n; i++)
|
||||
|
@ -10,10 +10,8 @@ const bench = common.createBenchmark(main, {
|
||||
|
||||
const vm = require('vm');
|
||||
|
||||
function main(conf) {
|
||||
const n = +conf.n;
|
||||
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
|
||||
const withSigintListener = !!conf.withSigintListener;
|
||||
function main({ n, breakOnSigint, withSigintListener }) {
|
||||
const options = breakOnSigint ? { breakOnSigint: true } : {};
|
||||
|
||||
process.removeAllListeners('SIGINT');
|
||||
if (withSigintListener)
|
||||
|
@ -10,10 +10,8 @@ const bench = common.createBenchmark(main, {
|
||||
|
||||
const vm = require('vm');
|
||||
|
||||
function main(conf) {
|
||||
const n = +conf.n;
|
||||
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
|
||||
const withSigintListener = !!conf.withSigintListener;
|
||||
function main({ n, breakOnSigint, withSigintListener }) {
|
||||
const options = breakOnSigint ? { breakOnSigint: true } : {};
|
||||
|
||||
process.removeAllListeners('SIGINT');
|
||||
if (withSigintListener)
|
||||
|
Loading…
x
Reference in New Issue
Block a user