forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetermine-specific-type.js
More file actions
58 lines (53 loc) · 1.23 KB
/
Copy pathdetermine-specific-type.js
File metadata and controls
58 lines (53 loc) · 1.23 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
const common = require('../common');
const bench = common.createBenchmark(main, {
n: [1e6],
v: [
'() => 1n',
'() => true',
'() => false',
'() => 2',
'() => +0',
'() => -0',
'() => NaN',
'() => Infinity',
'() => ""',
'() => "\'"',
'() => Symbol("foo")',
'() => function foo() {}',
'() => null',
'() => undefined',
'() => new Array()',
'() => new BigInt64Array()',
'() => new BigUint64Array()',
'() => new Int8Array()',
'() => new Int16Array()',
'() => new Int32Array()',
'() => new Float32Array()',
'() => new Float64Array()',
'() => new Uint8Array()',
'() => new Uint8ClampedArray()',
'() => new Uint16Array()',
'() => new Uint32Array()',
'() => new Date()',
'() => new Map()',
'() => new WeakMap()',
'() => new Object()',
'() => Promise.resolve("foo")',
'() => new Set()',
'() => new WeakSet()',
'() => ({ __proto__: null })',
],
}, {
flags: ['--expose-internals'],
});
function main({ n, v }) {
const {
determineSpecificType,
} = require('internal/errors');
const value = eval(v)();
bench.start();
for (let i = 0; i < n; ++i)
determineSpecificType(value);
bench.end(n);
}