-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Shorten the plan stack. #482
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
Conversation
@@ -303,6 +302,17 @@ PublicApi.prototype = enhanceAssert({ | |||
onError: onAssertionEvent | |||
}); | |||
|
|||
PublicApi.prototype.plan = plan; | |||
|
|||
function plan(ct) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just assign it directly to PublicApi.prototype.plan
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because plan
needs to be passed to Error.captureStackTrace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PublicApi.prototype.plan = function plan(ct) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - that works.
@sindresorhus Any thoughts on depth? I really think |
Yeah, doesn't make sense to have deeper stack trace for this as you only care about where the plan was defined. |
For performance improvements.
f01090b
to
341c84b
Compare
Changes made. |
👍 |
Every call to
t.plan
generates a stack trace. Apparently those stack traces are expensive. This speeds things up by shortening the stack trace.I am not sure we need more than a depth of 1.
benchmark:
master:
depth 1 (current value in this PR):
depth of 2:
depth of 3:
depth of 4: