Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools, benchmark: test util benchmark #16050

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions benchmark/util/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const bench = common.createBenchmark(main, {
});

function main({ n, type }) {
// For testing, if supplied with an empty type, default to string.
type = type || 'string';

const [first, second] = inputs[type];

bench.start();
Expand Down
3 changes: 3 additions & 0 deletions benchmark/util/inspect-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ function main({ n, len, type }) {
var arr = Array(len);
var i, opts;

// For testing, if supplied with an empty type, default to denseArray.
type = type || 'denseArray';

switch (type) {
case 'denseArray_showHidden':
opts = { showHidden: true };
Expand Down
7 changes: 5 additions & 2 deletions benchmark/util/type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ const bench = common.createBenchmark(main, {
type: Object.keys(args),
version: ['native', 'js'],
argument: ['true', 'false-primitive', 'false-object'],
millions: ['5']
n: [5e6]
}, {
flags: ['--expose-internals']
});

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 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 arg = args[conf.type][conf.argument];

Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-benchmark-util.js
Original file line number Diff line number Diff line change
@@ -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']);