-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
errors: improve performance of determine-specific-type
PR-URL: #49696 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
- Loading branch information
Showing
5 changed files
with
167 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters