Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test-benchmark-assert #15174

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 '':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be so kind and a a comment why this is necessary? Otherwise I would be confused by this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here and in the other 8 places it occurs in other files.

// 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
5 changes: 4 additions & 1 deletion benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ function main(conf) {
const actual = new clazz(len);
const expected = new clazz(len);
const expectedWrong = Buffer.alloc(len);
expectedWrong[100] = 123;
const wrongIndex = Math.floor(len / 2);
expectedWrong[wrongIndex] = 123;
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
12 changes: 12 additions & 0 deletions test/parallel/test-benchmark-assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

require('../common');

// Minimal test for assert benchmarks. This makes sure the benchmarks aren't
// completely broken but nothing more than that.

const runBenchmark = require('../common/benchmark');

runBenchmark(
'assert', ['len=1', 'method=', 'n=1', 'prim=null', 'size=1', 'type=Int8Array']
);