Skip to content

Commit

Permalink
benchmark: refactor deepequal-typedarrays
Browse files Browse the repository at this point in the history
This is a minor refactor of benchmark/assert/deepequal-typedarrays.js to
reduce exceptions that need to be made for lint compliance.

PR-URL: #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>
  • Loading branch information
Trott authored and MylesBorins committed Jun 6, 2018
1 parent 686587b commit b8470b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions benchmark/assert/deepequal-typedarrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ const bench = common.createBenchmark(main, {
});

function main({ type, n, len, method }) {
if (!method)
method = 'deepEqual';
const clazz = global[type];
const actual = new clazz(len);
const expected = new clazz(len);
const expectedWrong = Buffer.alloc(len);
const wrongIndex = Math.floor(len / 2);
expectedWrong[wrongIndex] = 123;

// eslint-disable-next-line no-restricted-properties
const fn = method !== '' ? assert[method] : assert.deepEqual;
const fn = assert[method];
const value2 = method.includes('not') ? expectedWrong : expected;

bench.start();
Expand Down

0 comments on commit b8470b9

Please sign in to comment.