2015-12-17 10:05:45 -03:00
|
|
|
'use strict';
|
2017-02-01 07:28:59 +08:00
|
|
|
const common = require('../common.js');
|
|
|
|
const assert = require('assert');
|
2017-06-28 20:34:19 +02:00
|
|
|
|
2017-02-01 07:28:59 +08:00
|
|
|
const bench = common.createBenchmark(main, {
|
2017-04-17 04:01:12 +03:00
|
|
|
type: [
|
|
|
|
'Int8Array',
|
|
|
|
'Uint8Array',
|
|
|
|
'Float32Array',
|
2023-02-09 22:07:11 +01:00
|
|
|
'Uint32Array',
|
2017-04-17 04:01:12 +03:00
|
|
|
],
|
2024-02-28 17:08:05 +08:00
|
|
|
n: [25000],
|
2018-08-03 15:30:22 +02:00
|
|
|
strict: [0, 1],
|
2017-06-28 20:34:19 +02:00
|
|
|
method: [
|
|
|
|
'deepEqual',
|
|
|
|
'notDeepEqual',
|
|
|
|
],
|
2019-01-31 21:05:17 -08:00
|
|
|
len: [1e2, 5e3],
|
2025-03-08 18:01:04 +01:00
|
|
|
}, {
|
|
|
|
combinationFilter(p) {
|
|
|
|
return p.strict === 1 ||
|
|
|
|
p.type !== 'Float32Array' ||
|
|
|
|
p.len === 1e2;
|
|
|
|
},
|
2015-12-17 10:05:45 -03:00
|
|
|
});
|
|
|
|
|
2018-08-03 15:30:22 +02:00
|
|
|
function main({ type, n, len, method, strict }) {
|
2017-02-01 07:28:59 +08:00
|
|
|
const clazz = global[type];
|
|
|
|
const actual = new clazz(len);
|
|
|
|
const expected = new clazz(len);
|
2015-12-17 10:05:45 -03:00
|
|
|
|
2018-08-03 15:30:22 +02:00
|
|
|
if (strict) {
|
|
|
|
method = method.replace('eep', 'eepStrict');
|
|
|
|
}
|
2018-05-30 03:53:11 +00:00
|
|
|
const fn = assert[method];
|
2023-02-09 22:07:11 +01:00
|
|
|
|
|
|
|
if (method.includes('not')) {
|
|
|
|
expected[Math.floor(len / 2)] = 123;
|
|
|
|
}
|
2018-01-23 13:17:21 +01:00
|
|
|
|
|
|
|
bench.start();
|
2019-11-12 19:56:03 +01:00
|
|
|
for (let i = 0; i < n; ++i) {
|
2018-08-03 15:30:22 +02:00
|
|
|
actual[0] = i;
|
2023-02-09 22:07:11 +01:00
|
|
|
expected[0] = i;
|
|
|
|
const pos = Math.ceil(len / 2) + 1;
|
|
|
|
actual[pos] = i;
|
|
|
|
expected[pos] = i;
|
|
|
|
fn(actual, expected);
|
2017-02-01 07:28:59 +08:00
|
|
|
}
|
2018-01-23 13:17:21 +01:00
|
|
|
bench.end(n);
|
2015-12-17 10:05:45 -03:00
|
|
|
}
|