benchmark: refactor deepequal-buffer
This is a minor refactor of benchmark/assert/deepequal-buffer.js to reduce exceptions that need to be made for lint compliance. PR-URL: https://github.com/nodejs/node/pull/21030 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
6168959546
commit
206b19cc3f
@ -14,6 +14,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ len, n, method }) {
|
function main({ len, n, method }) {
|
||||||
|
if (!method)
|
||||||
|
method = 'deepEqual';
|
||||||
const data = Buffer.allocUnsafe(len + 1);
|
const data = Buffer.allocUnsafe(len + 1);
|
||||||
const actual = Buffer.alloc(len);
|
const actual = Buffer.alloc(len);
|
||||||
const expected = Buffer.alloc(len);
|
const expected = Buffer.alloc(len);
|
||||||
@ -22,8 +24,7 @@ function main({ len, n, method }) {
|
|||||||
data.copy(expected);
|
data.copy(expected);
|
||||||
data.copy(expectedWrong);
|
data.copy(expectedWrong);
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-properties
|
const fn = assert[method];
|
||||||
const fn = method !== '' ? assert[method] : assert.deepEqual;
|
|
||||||
const value2 = method.includes('not') ? expectedWrong : expected;
|
const value2 = method.includes('not') ? expectedWrong : expected;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user