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: #15174
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and jasnell committed Sep 20, 2017
1 parent b5c1a82 commit d30a583
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 @@ -37,6 +37,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 d30a583

Please sign in to comment.