Uh oh!
There was an error while loading. Please reload this page.
util(styleText): optimise + benchmark - #58063
Conversation
nodejs-github-bot
commented
Apr 28, 2025
Review requested:
|
Codecov Report✅ All 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. |
AugustinMauroy
commented
Apr 28, 2025
oh okay, surprising because the use cases with the |
7e02fbd to
369b13fCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cf38ccd to
ae69a04CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| @@ -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.
early return will skip validation so its a necessary overhead
#56722 (comment)
RafaelGSS
left a comment
There was a problem hiding this comment.
As Marco mentioned, the "overhead" is necessary.
AugustinMauroy
commented
Apr 29, 2025
Can I just keep benchmark change ? |
RafaelGSS
commented
Apr 29, 2025
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 <duhamelantoine1995@gmail.com>
029701a to
ef34ff0Compare| validateStream: [1, 0], | ||
| n: [1e3], | ||
| }); | ||
| withColor: { |
There was a problem hiding this comment.
Please, create a different file instead. style-text-nocolor.js
This pull request has been marked as stale due to 210 days of inactivity. |
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:testin goal of having better DX when something fails.