Add bechmarks for chalk 5 and yoctocolors #61
+438
−59
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.
Fixes #45.
Changes
The latest version of
chalk
does not support CJS, but it is possible to bundle it in the CJS format. It is worth testing the latest available version.yoctocolors
does not support CJS, but it is possible to bundle it in the CJS format. This library aspires to be the new tiniest one. It supportsFORCE_COLOR
andNO_COLOR
too. It is worth comparing it topicocolors
.Split
chalk
tochalk4
andchalk5
using NPM module aliases. Also upgrade development dependencies. Keep the same major version ofclean-publish
not to break the legacy Node.js tests.Use
esbuild
to create CJS bundles ofchalk5
andyoctocolors
. Addchalk5
andyoctocolors
to every benchmark. Rename the formerchalk
tests tochalk4
.Results
The
simple.js
benchmark shows 5% decrease of performance inchalk
5 againstchalk
4.yoctocolors
beatpicocolors
by 284%.The
complex.js
benchmark shows 3% decrease of performance inchalk
5 againstchalk
4.yoctocolors
beatpicocolors
by 61%.The
loading.js
benchmark shows 44% decrease of performance inchalk
5 againstchalk
4.yoctocolors
is 75% slower thanpicocolors
. I tried replacing the color detection inyoctocolors
with the code frompicocolors
and the loading time went down to 0.588 ms, 52% slower thanpicocolors
.The
size.js
benchmark shows 57% size reduction forchalk
5 againstchalk
4.yoctocolors
is practically the same aspicocolors
. This benchmark isn't reliable, because the size of the actually used code may be much smaller, as the comparison of the single-file librariesyoctocolors
andpicocolors
shows.