-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Conversation
6886e9c
to
4189118
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there
benchmark/assert/deepequal-buffer.js
Outdated
data.copy(actual); | ||
data.copy(expected); | ||
|
||
if (conf.strict === 'strict') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
4189118
to
f26fa6a
Compare
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks
@jasnell Thanks for the review, updated, PTAL. |
Aside: one of the try runs of |
hmm... I'm not sure I'm seeing that. Worth pinging @nodejs/v8 tho just in case. |
FYI: I was playing with different |
Going to land this in 24 hours |
Landed in 5e4545e |
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: #11092 Reviewed-By: James M Snell <jasnell@gmail.com>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: #11092 Reviewed-By: James M Snell <jasnell@gmail.com>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: nodejs#11092 Reviewed-By: James M Snell <jasnell@gmail.com>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: nodejs#11092 Reviewed-By: James M Snell <jasnell@gmail.com>
would need a backport PR to land on v4 |
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: #11092 Reviewed-By: James M Snell <jasnell@gmail.com>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: #11092 Reviewed-By: James M Snell <jasnell@gmail.com>
Refs: #10282 (review)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
benchmark, assert