• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const assert = require('assert');
4
5const primValues = {
6  'string': 'a',
7  'number': 1,
8  'object': { 0: 'a' },
9  'array': [1, 2, 3],
10};
11
12const bench = common.createBenchmark(main, {
13  primitive: Object.keys(primValues),
14  n: [2e4],
15  strict: [0, 1],
16  method: ['deepEqual', 'notDeepEqual'],
17});
18
19function main({ n, primitive, method, strict }) {
20  const prim = primValues[primitive];
21  const actual = prim;
22  const expected = prim;
23  const expectedWrong = 'b';
24
25  if (strict) {
26    method = method.replace('eep', 'eepStrict');
27  }
28  const fn = assert[method];
29  const value2 = method.includes('not') ? expectedWrong : expected;
30
31  bench.start();
32  for (let i = 0; i < n; ++i) {
33    fn([actual], [value2]);
34  }
35  bench.end(n);
36}
37