benchmark: add assert.deep[Strict]Equal benchmarks#11092
benchmark: add assert.deep[Strict]Equal benchmarks#11092joyeecheung wants to merge 1 commit intonodejs:masterfrom
Conversation
6886e9c to
4189118
Compare
benchmark/assert/deepequal-buffer.js
Outdated
There was a problem hiding this comment.
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.
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 <[email protected]>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: #11092 Reviewed-By: James M Snell <[email protected]>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: nodejs#11092 Reviewed-By: James M Snell <[email protected]>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: nodejs#11092 Reviewed-By: James M Snell <[email protected]>
|
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 <[email protected]>
* Move numbers into configuration * Add buffer comparison benchmark * Add assert.deepStrictEqual benchmarks PR-URL: #11092 Reviewed-By: James M Snell <[email protected]>
Refs: #10282 (review)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
benchmark, assert