Skip to content

Commit

Permalink
benchmark: provide default methods for assert
Browse files Browse the repository at this point in the history
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: nodejs/node#15174
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and addaleax committed Sep 17, 2017
1 parent e2b00b4 commit 502f4e6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-prims-and-objs-big-array-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-prims-and-objs-big-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions benchmark/assert/throws.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 502f4e6

Please sign in to comment.