11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common.js');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst primValues = {
61cb0ef41Sopenharmony_ci  'string': 'a',
71cb0ef41Sopenharmony_ci  'number': 1,
81cb0ef41Sopenharmony_ci  'object': { 0: 'a' },
91cb0ef41Sopenharmony_ci  'array': [1, 2, 3],
101cb0ef41Sopenharmony_ci};
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, {
131cb0ef41Sopenharmony_ci  primitive: Object.keys(primValues),
141cb0ef41Sopenharmony_ci  n: [2e4],
151cb0ef41Sopenharmony_ci  strict: [0, 1],
161cb0ef41Sopenharmony_ci  method: ['deepEqual', 'notDeepEqual'],
171cb0ef41Sopenharmony_ci});
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cifunction main({ n, primitive, method, strict }) {
201cb0ef41Sopenharmony_ci  const prim = primValues[primitive];
211cb0ef41Sopenharmony_ci  const actual = prim;
221cb0ef41Sopenharmony_ci  const expected = prim;
231cb0ef41Sopenharmony_ci  const expectedWrong = 'b';
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  if (strict) {
261cb0ef41Sopenharmony_ci    method = method.replace('eep', 'eepStrict');
271cb0ef41Sopenharmony_ci  }
281cb0ef41Sopenharmony_ci  const fn = assert[method];
291cb0ef41Sopenharmony_ci  const value2 = method.includes('not') ? expectedWrong : expected;
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  bench.start();
321cb0ef41Sopenharmony_ci  for (let i = 0; i < n; ++i) {
331cb0ef41Sopenharmony_ci    fn([actual], [value2]);
341cb0ef41Sopenharmony_ci  }
351cb0ef41Sopenharmony_ci  bench.end(n);
361cb0ef41Sopenharmony_ci}
37