Browse Source

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>
canary-base
Rich Trott 8 years ago
committed by James M Snell
parent
commit
3c4c0db26a
  1. 2
      benchmark/assert/deepequal-buffer.js
  2. 2
      benchmark/assert/deepequal-map.js
  3. 2
      benchmark/assert/deepequal-object.js
  4. 2
      benchmark/assert/deepequal-prims-and-objs-big-array-set.js
  5. 2
      benchmark/assert/deepequal-prims-and-objs-big-loop.js
  6. 2
      benchmark/assert/deepequal-set.js
  7. 2
      benchmark/assert/deepequal-typedarrays.js
  8. 2
      benchmark/assert/throws.js

2
benchmark/assert/deepequal-buffer.js

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

2
benchmark/assert/deepequal-map.js

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

2
benchmark/assert/deepequal-object.js

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

2
benchmark/assert/deepequal-prims-and-objs-big-array-set.js

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

2
benchmark/assert/deepequal-prims-and-objs-big-loop.js

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

2
benchmark/assert/deepequal-set.js

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

2
benchmark/assert/deepequal-typedarrays.js

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

2
benchmark/assert/throws.js

@ -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…
Cancel
Save