• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const assert = require('assert');
4
5const bench = common.createBenchmark(main, {
6  n: [2e4],
7  len: [1e2, 1e3],
8  strict: [0, 1],
9  method: ['deepEqual', 'notDeepEqual'],
10});
11
12function main({ len, n, method, strict }) {
13  const data = Buffer.allocUnsafe(len + 1);
14  const actual = Buffer.alloc(len);
15  const expected = Buffer.alloc(len);
16  const expectedWrong = Buffer.alloc(len + 1);
17  data.copy(actual);
18  data.copy(expected);
19  data.copy(expectedWrong);
20
21  if (strict) {
22    method = method.replace('eep', 'eepStrict');
23  }
24  const fn = assert[method];
25  const value2 = method.includes('not') ? expectedWrong : expected;
26
27  bench.start();
28  for (let i = 0; i < n; ++i) {
29    fn(actual, value2);
30  }
31  bench.end(n);
32}
33