-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
util(styleText): optimise + benchmark #58063
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
base: main
Are you sure you want to change the base?
util(styleText): optimise + benchmark #58063
Conversation
Review requested:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58063 +/- ##
=======================================
Coverage 90.21% 90.21%
=======================================
Files 630 630
Lines 186391 186448 +57
Branches 36610 36620 +10
=======================================
+ Hits 168146 168209 +63
+ Misses 11066 11038 -28
- Partials 7179 7201 +22
🚀 New features to boost your workflow:
|
Please don't do that, we discussed it a lot. Those refactors are not useful. |
oh okay, surprising because the use cases with the |
7e02fbd
to
369b13f
Compare
cf38ccd
to
ae69a04
Compare
lib/util.js
Outdated
@@ -129,8 +128,9 @@ function styleText(format, text, { validateStream = true, stream = process.stdou | |||
throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream); | |||
} | |||
|
|||
// If the stream is falsy or should not be colorized, set skipColorize to true | |||
skipColorize = !lazyUtilColors().shouldColorize(stream); | |||
if (!lazyUtilColors().shouldColorize(stream)) { |
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.
early return will skip validation so its a necessary overhead
#56722 (comment)
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.
As Marco mentioned, the "overhead" is necessary.
Can I just keep benchmark change ? |
Yes, but I'd do it as a separate benchmark, so we don't need to have benchmarks for: noColors: true, format: 'italic', As they will all be the same. So, adding it as a separate benchmark makes more sense. |
Co-Authored-By: Antoine du Hamel <[email protected]>
029701a
to
ef34ff0
Compare
validateStream: [1, 0], | ||
n: [1e3], | ||
}); | ||
withColor: { |
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.
Please, create a different file instead. style-text-nocolor.js
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.
oh okay got it !
I had modify logic behind. using a reducer, it's should be quicker. And I had updated benchmark
Plus I had updated test to usenode:test
in goal of having better DX when something fails.