benchmark: refactor util benchmarks
This significantly reduces the benchmark runtime. It removes to many variations that do not provide any benefit and reduces the iterations. PR-URL: https://github.com/nodejs/node/pull/22503 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
af2e5f9522
commit
de33a5aa6e
@ -16,7 +16,7 @@ const inputs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [4e6],
|
n: [1e5],
|
||||||
type: Object.keys(inputs)
|
type: Object.keys(inputs)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ const common = require('../common');
|
|||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1e3],
|
n: [5e2],
|
||||||
len: [1e5],
|
len: [1e2, 1e5],
|
||||||
type: [
|
type: [
|
||||||
'denseArray',
|
'denseArray',
|
||||||
'sparseArray',
|
'sparseArray',
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const util = require('util');
|
const util = require('util');
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, { n: [1e6] });
|
const bench = common.createBenchmark(main, { n: [2e4] });
|
||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
const proxyA = new Proxy({}, { get: () => {} });
|
const proxyA = new Proxy({}, { get: () => {} });
|
||||||
|
@ -9,7 +9,7 @@ const opts = {
|
|||||||
none: undefined
|
none: undefined
|
||||||
};
|
};
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [2e6],
|
n: [2e4],
|
||||||
method: [
|
method: [
|
||||||
'Object',
|
'Object',
|
||||||
'Object_empty',
|
'Object_empty',
|
||||||
@ -81,7 +81,7 @@ function main({ method, n, option }) {
|
|||||||
benchmark(n, new Error('error'), options);
|
benchmark(n, new Error('error'), options);
|
||||||
break;
|
break;
|
||||||
case 'Array':
|
case 'Array':
|
||||||
benchmark(n, Array(20).fill().map((_, i) => i), options);
|
benchmark(n, Array(50).fill().map((_, i) => i), options);
|
||||||
break;
|
break;
|
||||||
case 'TypedArray':
|
case 'TypedArray':
|
||||||
obj = new Uint8Array(Array(50).fill().map((_, i) => i));
|
obj = new Uint8Array(Array(50).fill().map((_, i) => i));
|
||||||
|
@ -5,26 +5,23 @@ const assert = require('assert');
|
|||||||
|
|
||||||
const groupedInputs = {
|
const groupedInputs = {
|
||||||
group_common: ['undefined', 'utf8', 'utf-8', 'base64',
|
group_common: ['undefined', 'utf8', 'utf-8', 'base64',
|
||||||
'binary', 'latin1', 'ucs-2'],
|
'binary', 'latin1', 'ucs2'],
|
||||||
group_upper: ['UTF-8', 'UTF8', 'UCS2', 'UTF-16LE',
|
group_upper: ['UTF-8', 'UTF8', 'UCS2',
|
||||||
'UTF16LE', 'BASE64', 'UCS-2'],
|
'UTF16LE', 'BASE64', 'UCS2'],
|
||||||
group_uncommon: ['foo', '1', 'false', 'undefined', '[]', '{}'],
|
group_uncommon: ['foo'],
|
||||||
group_misc: ['', 'utf16le', 'hex', 'HEX', 'BINARY']
|
group_misc: ['', 'utf16le', 'hex', 'HEX', 'BINARY']
|
||||||
};
|
};
|
||||||
|
|
||||||
const inputs = [
|
const inputs = [
|
||||||
'',
|
'', 'utf8', 'utf-8', 'UTF-8', 'UTF8', 'Utf8',
|
||||||
'utf8', 'utf-8', 'UTF-8',
|
'ucs2', 'UCS2', 'utf16le', 'UTF16LE',
|
||||||
'UTF8', 'Utf8', 'uTf-8', 'utF-8',
|
|
||||||
'ucs2', 'UCS2', 'UcS2',
|
|
||||||
'ucs-2', 'UCS-2', 'UcS-2',
|
|
||||||
'utf16le', 'utf-16le', 'UTF-16LE', 'UTF16LE',
|
|
||||||
'binary', 'BINARY', 'latin1', 'base64', 'BASE64',
|
'binary', 'BINARY', 'latin1', 'base64', 'BASE64',
|
||||||
'hex', 'HEX', 'foo', '1', 'false', 'undefined', '[]', '{}'];
|
'hex', 'HEX', 'foo', 'undefined'
|
||||||
|
];
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
input: inputs.concat(Object.keys(groupedInputs)),
|
input: inputs.concat(Object.keys(groupedInputs)),
|
||||||
n: [1e7]
|
n: [1e5]
|
||||||
}, {
|
}, {
|
||||||
flags: '--expose-internals'
|
flags: '--expose-internals'
|
||||||
});
|
});
|
||||||
@ -39,16 +36,8 @@ function getInput(input) {
|
|||||||
return groupedInputs.group_uncommon;
|
return groupedInputs.group_uncommon;
|
||||||
case 'group_misc':
|
case 'group_misc':
|
||||||
return groupedInputs.group_misc;
|
return groupedInputs.group_misc;
|
||||||
case '1':
|
|
||||||
return [1];
|
|
||||||
case 'false':
|
|
||||||
return [false];
|
|
||||||
case 'undefined':
|
case 'undefined':
|
||||||
return [undefined];
|
return [undefined];
|
||||||
case '[]':
|
|
||||||
return [[]];
|
|
||||||
case '{}':
|
|
||||||
return [{}];
|
|
||||||
default:
|
default:
|
||||||
return [input];
|
return [input];
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1e6]
|
n: [1e5]
|
||||||
}, { flags: ['--expose-internals'] });
|
}, { flags: ['--expose-internals'] });
|
||||||
|
|
||||||
function main({ n, type }) {
|
function main({ n, type }) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
n: [1e7],
|
n: [1e5],
|
||||||
pos: ['start', 'middle', 'end'],
|
pos: ['start', 'middle', 'end'],
|
||||||
size: [10, 100, 500],
|
size: [10, 100, 500],
|
||||||
}, { flags: ['--expose-internals'] });
|
}, { flags: ['--expose-internals'] });
|
||||||
|
@ -29,7 +29,7 @@ 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'],
|
||||||
n: [5e6]
|
n: [1e5]
|
||||||
}, {
|
}, {
|
||||||
flags: ['--expose-internals']
|
flags: ['--expose-internals']
|
||||||
});
|
});
|
||||||
|
@ -13,5 +13,6 @@ runBenchmark('util',
|
|||||||
'pos=start',
|
'pos=start',
|
||||||
'size=1',
|
'size=1',
|
||||||
'type=',
|
'type=',
|
||||||
|
'len=1',
|
||||||
'version=native'],
|
'version=native'],
|
||||||
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user