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

benchmark: add assert.deep[Strict]Equal benchmarks #11092

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@joyeecheung
Member

joyeecheung commented Jan 31, 2017

  • Move numbers into configuration
  • Add buffer comparison benchmark
  • Add assert.deepStrictEqual benchmarks

Refs: #10282 (review)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

benchmark, assert

@jasnell

Almost there

Show outdated Hide outdated benchmark/assert/deepequal-buffer.js
data.copy(actual);
data.copy(expected);
if (conf.strict === 'strict') {

This comment has been minimized.

@jasnell

jasnell Feb 1, 2017

Member

In other benchmarks we've used the pattern:

switch (conf.strict) {
  case 'strict':
    /** do stuff **/
  case 'nonstrict':
    /** do stuff **/
  default:
    throw new Error('Unsupported method');
}

This makes it easier to plug in new choices later and makes a code a bit easier to follow

@jasnell

jasnell Feb 1, 2017

Member

In other benchmarks we've used the pattern:

switch (conf.strict) {
  case 'strict':
    /** do stuff **/
  case 'nonstrict':
    /** do stuff **/
  default:
    throw new Error('Unsupported method');
}

This makes it easier to plug in new choices later and makes a code a bit easier to follow

This comment has been minimized.

@jasnell

jasnell Feb 1, 2017

Member

It's also possible to simplify this further by doing something like:

var method;
switch (conf.strict) {
  case 'strict':
    method = assert.deepStrictEqual;
    break;
  case 'nonstrict':
    method = assert.deepEqual;
    break;
  default:
    throw new Error('...');
}
bench.start();
for (i = 0; i < n; ++i)
  method(actual, expected);
bench.end(n);

Or even:

const methods = {
  'strict': assert.deepStrictEqual,
  'nonstrict': assert.deepEqual
};
const method = methods[conf.strict];
if (!method) throw new Error('...');
bench.start();
for (i = 0; i < n; ++i)
  method(actual, expected);
bench.end(n);
@jasnell

jasnell Feb 1, 2017

Member

It's also possible to simplify this further by doing something like:

var method;
switch (conf.strict) {
  case 'strict':
    method = assert.deepStrictEqual;
    break;
  case 'nonstrict':
    method = assert.deepEqual;
    break;
  default:
    throw new Error('...');
}
bench.start();
for (i = 0; i < n; ++i)
  method(actual, expected);
bench.end(n);

Or even:

const methods = {
  'strict': assert.deepStrictEqual,
  'nonstrict': assert.deepEqual
};
const method = methods[conf.strict];
if (!method) throw new Error('...');
bench.start();
for (i = 0; i < n; ++i)
  method(actual, expected);
bench.end(n);
benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks
@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

joyeecheung Feb 1, 2017

Member

@jasnell Thanks for the review, updated, PTAL.

Member

joyeecheung commented Feb 1, 2017

@jasnell Thanks for the review, updated, PTAL.

@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

joyeecheung Feb 2, 2017

Member

Aside: one of the try runs of Float32Array benchmarks raises the assertion, could be a V8 bug but I am not able to reproduce it.

Member

joyeecheung commented Feb 2, 2017

Aside: one of the try runs of Float32Array benchmarks raises the assertion, could be a V8 bug but I am not able to reproduce it.

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Feb 2, 2017

Member

hmm... I'm not sure I'm seeing that. Worth pinging @nodejs/v8 tho just in case.

Member

jasnell commented Feb 2, 2017

hmm... I'm not sure I'm seeing that. Worth pinging @nodejs/v8 tho just in case.

@jasnell

jasnell approved these changes Feb 2, 2017

@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

joyeecheung Feb 2, 2017

Member

FYI: I was playing with different n and len in deepequal-typedarrays.js when the assertion was raised. Can't remember what they were but definitely not 1 and 1e6 as they are now. At least n is not 1. And I don't even know if it's the old deepEqual (or deepStrictEqual) or if it's the new one in #10282 that raised this. Sorry I don't have more clues :/ I closed the session too soon, so probably not really worth digging into.

Member

joyeecheung commented Feb 2, 2017

FYI: I was playing with different n and len in deepequal-typedarrays.js when the assertion was raised. Can't remember what they were but definitely not 1 and 1e6 as they are now. At least n is not 1. And I don't even know if it's the old deepEqual (or deepStrictEqual) or if it's the new one in #10282 that raised this. Sorry I don't have more clues :/ I closed the session too soon, so probably not really worth digging into.

@joyeecheung joyeecheung referenced this pull request Feb 2, 2017

Closed

assert: fix _deepEqual and improve assert.md #11128

4 of 4 tasks complete
@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

joyeecheung Feb 4, 2017

Member

Going to land this in 24 hours

Member

joyeecheung commented Feb 4, 2017

Going to land this in 24 hours

@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

joyeecheung Feb 6, 2017

Member

Landed in 5e4545e

Member

joyeecheung commented Feb 6, 2017

Landed in 5e4545e

@joyeecheung joyeecheung closed this Feb 6, 2017

joyeecheung added a commit that referenced this pull request Feb 6, 2017

benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks

PR-URL: #11092
Reviewed-By: James M Snell <jasnell@gmail.com>

italoacasas added a commit that referenced this pull request Feb 6, 2017

benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks

PR-URL: #11092
Reviewed-By: James M Snell <jasnell@gmail.com>

italoacasas added a commit to italoacasas/node that referenced this pull request Feb 14, 2017

benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks

PR-URL: nodejs#11092
Reviewed-By: James M Snell <jasnell@gmail.com>

@joyeecheung joyeecheung deleted the joyeecheung:assert-benchmark branch Feb 19, 2017

KryDos added a commit to KryDos/node that referenced this pull request Feb 25, 2017

benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks

PR-URL: nodejs#11092
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Mar 7, 2017

Member

would need a backport PR to land on v4

Member

jasnell commented Mar 7, 2017

would need a backport PR to land on v4

jasnell added a commit that referenced this pull request Mar 7, 2017

benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks

PR-URL: #11092
Reviewed-By: James M Snell <jasnell@gmail.com>

MylesBorins added a commit that referenced this pull request Mar 9, 2017

benchmark: add assert.deep[Strict]Equal benchmarks
* Move numbers into configuration
* Add buffer comparison benchmark
* Add assert.deepStrictEqual benchmarks

PR-URL: #11092
Reviewed-By: James M Snell <jasnell@gmail.com>

@MylesBorins MylesBorins referenced this pull request Mar 9, 2017

Merged

v6.10.1 proposal #11759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment