-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
errors: improve error creation performance #46648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ed1a664
errors: improve hideInternalStackFrames performance
BridgeAR d21f72b
errors: reuse addNumericSeparator from internal inspect
BridgeAR b287852
lib: make sure internal assertions use internal/assert
BridgeAR c4f3517
net: reuse existing aggregateTwoErrors functionality
BridgeAR 0d72d40
errors: minor performance improvement
BridgeAR 2d8a4a3
errors: improve NodeError creation performance
BridgeAR 69df124
errors: do not remove already collected stack frames in NodeErrors
BridgeAR 4ddd43f
errors: format more numbers with numeric separator
BridgeAR 087b0bc
errors: improve NodeError creation performance
BridgeAR 6ec603c
lib: add new to construct errors
BridgeAR 08e1c89
errors: significantly improve NodeError creation performance
BridgeAR b3aa706
test_runner: set the properties inside of the error method
BridgeAR 72f87e9
errors,repl: align prepareStackTrace behavior
BridgeAR ee8e40f
errors: remove unused ERR_INVALID_RETURN_PROPERTY error
BridgeAR 40ab9c3
errors: faster ERR_MODULE_NOT_FOUND error
BridgeAR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,21 +1,34 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
|
|
||
| const bench = common.createBenchmark(main, { | ||
| n: [1e7], | ||
| n: [1e5], | ||
| type: ['node', 'regular'], | ||
| }, { | ||
| flags: ['--expose-internals'], | ||
| }); | ||
|
|
||
| function main({ n }) { | ||
| function main({ n, type }) { | ||
| const { | ||
| codes: { | ||
| ERR_INVALID_STATE, | ||
| }, | ||
| } = require('internal/errors'); | ||
|
|
||
| const Clazz = type === 'node' ? ERR_INVALID_STATE.TypeError : (() => { | ||
| class Foo extends TypeError {} | ||
| Foo.prototype.constructor = TypeError; | ||
| return Foo; | ||
| })(); | ||
|
|
||
| bench.start(); | ||
| for (let i = 0; i < n; ++i) | ||
| new ERR_INVALID_STATE.TypeError('test'); | ||
| let length = 0; | ||
| for (let i = 0; i < n; i++) { | ||
| const error = new Clazz('test' + i); | ||
| length += error.name.length; | ||
| } | ||
| bench.end(n); | ||
| assert(length); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.