Welcome to mirror list, hosted at ThFree Co, Russian Federation.

deepequal-typedarrays.js « assert « benchmark - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 037cfb2cf1ec3ca3722008781ad6d74753603279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
  type: ('Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array ' +
    'Float32Array Float64Array Uint8ClampedArray').split(' '),
  n: [1],
  method: ['strict', 'nonstrict'],
  len: [1e6]
});

function main(conf) {
  const type = conf.type;
  const clazz = global[type];
  const n = +conf.n;
  const len = +conf.len;

  const actual = new clazz(len);
  const expected = new clazz(len);
  var i;

  switch (conf.method) {
    case 'strict':
      bench.start();
      for (i = 0; i < n; ++i) {
        // eslint-disable-next-line no-restricted-properties
        assert.deepEqual(actual, expected);
      }
      bench.end(n);
      break;
    case 'nonstrict':
      bench.start();
      for (i = 0; i < n; ++i) {
        assert.deepStrictEqual(actual, expected);
      }
      bench.end(n);
      break;
    default:
      throw new Error('Unsupported method');
  }
}