benchmark: provide default methods for assert
The benchmarks for `assert` all take a `method` configuration option, but the allowable values are different across the files. For each benchmark, provide an arbitrary default if `method` is set to an empty string. This allows all the `assert` benchmarks to be run with a single command but only on a single method. This is primarily useful for testing that the assert benchmark files don't contain egregious errors. (In other words, it's useful for testing.) PR-URL: https://github.com/nodejs/node/pull/15174 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
11f46a2586
commit
3c4c0db26a
@ -27,6 +27,8 @@ function main(conf) {
|
||||
data.copy(expectedWrong);
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual':
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -46,6 +46,8 @@ function main(conf) {
|
||||
var values, values2;
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual_primitiveOnly':
|
||||
values = array.map((_, i) => [`str_${i}`, 123]);
|
||||
benchmark(assert.deepEqual, n, values);
|
||||
|
@ -37,6 +37,8 @@ function main(conf) {
|
||||
const expectedWrong = createObj(source, '4');
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual':
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -53,6 +53,8 @@ function main(conf) {
|
||||
const expectedWrongSet = new Set(expectedWrong);
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual_Array':
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -34,6 +34,8 @@ function main(conf) {
|
||||
|
||||
// Creates new array to avoid loop invariant code motion
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual':
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -47,6 +47,8 @@ function main(conf) {
|
||||
var values, values2;
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual_primitiveOnly':
|
||||
values = array.map((_, i) => `str_${i}`);
|
||||
benchmark(assert.deepEqual, n, values);
|
||||
|
@ -38,6 +38,8 @@ function main(conf) {
|
||||
var i;
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'deepEqual':
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
@ -22,6 +22,8 @@ function main(conf) {
|
||||
var i;
|
||||
|
||||
switch (conf.method) {
|
||||
case '':
|
||||
// Empty string falls through to next line as default, mostly for tests.
|
||||
case 'doesNotThrow':
|
||||
bench.start();
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user