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:
Rich Trott 2017-09-03 14:06:09 -07:00 committed by James M Snell
parent 11f46a2586
commit 3c4c0db26a
8 changed files with 16 additions and 0 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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) {