tools, benchmark: test util benchmark
Create a minimal test for the util benchmark files. PR-URL: https://github.com/nodejs/node/pull/16050 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
parent
64aded33ef
commit
50fe1a8409
@ -21,6 +21,9 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, type }) {
|
function main({ n, type }) {
|
||||||
|
// For testing, if supplied with an empty type, default to string.
|
||||||
|
type = type || 'string';
|
||||||
|
|
||||||
const [first, second] = inputs[type];
|
const [first, second] = inputs[type];
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
@ -18,6 +18,9 @@ function main({ n, len, type }) {
|
|||||||
var arr = Array(len);
|
var arr = Array(len);
|
||||||
var i, opts;
|
var i, opts;
|
||||||
|
|
||||||
|
// For testing, if supplied with an empty type, default to denseArray.
|
||||||
|
type = type || 'denseArray';
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'denseArray_showHidden':
|
case 'denseArray_showHidden':
|
||||||
opts = { showHidden: true };
|
opts = { showHidden: true };
|
||||||
|
@ -29,16 +29,19 @@ const bench = common.createBenchmark(main, {
|
|||||||
type: Object.keys(args),
|
type: Object.keys(args),
|
||||||
version: ['native', 'js'],
|
version: ['native', 'js'],
|
||||||
argument: ['true', 'false-primitive', 'false-object'],
|
argument: ['true', 'false-primitive', 'false-object'],
|
||||||
millions: ['5']
|
n: [5e6]
|
||||||
}, {
|
}, {
|
||||||
flags: ['--expose-internals']
|
flags: ['--expose-internals']
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main(conf) {
|
||||||
|
// For testing, if supplied with an empty type, default to ArrayBufferView.
|
||||||
|
conf.type = conf.type || 'ArrayBufferView';
|
||||||
|
|
||||||
const util = process.binding('util');
|
const util = process.binding('util');
|
||||||
const types = require('internal/util/types');
|
const types = require('internal/util/types');
|
||||||
|
|
||||||
const n = (+conf.millions * 1e6) | 0;
|
const n = (+conf.n) | 0;
|
||||||
const func = { native: util, js: types }[conf.version][`is${conf.type}`];
|
const func = { native: util, js: types }[conf.version][`is${conf.type}`];
|
||||||
const arg = args[conf.type][conf.argument];
|
const arg = args[conf.type][conf.argument];
|
||||||
|
|
||||||
|
14
test/parallel/test-benchmark-util.js
Normal file
14
test/parallel/test-benchmark-util.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
const runBenchmark = require('../common/benchmark');
|
||||||
|
|
||||||
|
runBenchmark('util',
|
||||||
|
['argument=false',
|
||||||
|
'input=',
|
||||||
|
'method=Array',
|
||||||
|
'n=1',
|
||||||
|
'option=none',
|
||||||
|
'type=',
|
||||||
|
'version=native']);
|
Loading…
x
Reference in New Issue
Block a user