1'use strict'; 2const common = require('../common.js'); 3const assert = require('assert'); 4 5const bench = common.createBenchmark(main, { 6 type: [ 7 'Int8Array', 8 'Uint8Array', 9 'Float32Array', 10 'Float64Array', 11 'Uint8ClampedArray', 12 ], 13 n: [5e2], 14 strict: [0, 1], 15 method: [ 16 'deepEqual', 17 'notDeepEqual', 18 ], 19 len: [1e2, 5e3], 20}); 21 22function main({ type, n, len, method, strict }) { 23 const clazz = global[type]; 24 const actual = new clazz(len); 25 const expected = new clazz(len); 26 const expectedWrong = new clazz(len); 27 const wrongIndex = Math.floor(len / 2); 28 expectedWrong[wrongIndex] = 123; 29 30 if (strict) { 31 method = method.replace('eep', 'eepStrict'); 32 } 33 const fn = assert[method]; 34 const value2 = method.includes('not') ? expectedWrong : expected; 35 36 bench.start(); 37 for (let i = 0; i < n; ++i) { 38 actual[0] = i; 39 value2[0] = i; 40 fn(actual, value2); 41 } 42 bench.end(n); 43} 44