-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add bechmarks for chalk 5 and yoctocolors #61
Add bechmarks for chalk 5 and yoctocolors #61
Conversation
d37a6a6
to
1cd18ec
Compare
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 supports `FORCE_COLOR` and `NO_COLOR` too. It is worth comparing it to `picocolors`. Split `chalk` to `chalk4` and `chalk5` using NPM module aliases. Also upgrade development dependencies. Keep the same major version of `clean-publish` not to break the legacy Node.js tests. Use `esbuild` to create CJS bundles of `chalk5` and `yoctocolors`. Add `chalk5` and `yoctocolors` to every benchmark. Rename the former `chalk` tests to `chalk4`. Correct the number formatting to allow one more decimal place.
1cd18ec
to
e50360d
Compare
Copy the `simple` and `complex` benchmarks and convert the module-importing code. Use the dynamic import to measure the loading time of ESM modules. The `--esm` argument enables the ESM mode.
It does not support NPM package aliases needed for tests of `chalk` 4 and `chalk` 5. It could be worked around by an additional `package.json`, but it is probably not worth the effort.
Thank you for taking time to contribute! I will need a bit more time to thoroughly review the changes, apologies for the delay. The very least I can say is that the decision to drop Node.js v6 should not be in the scope of this PR. This is something better be done in a separate PR and dropping anything below v10.16 would allow us to simplify color detection by a lot. Most likely a breaking change, so we gotta check if the largest user would be okay with it moving forward cc @ai Another thing I'd like to point out is that Let's remove yoctocolors from benchmarks. |
Browserslist supports Node.js 6 and releasing new major is very painful for the project. But I think I can just avoid requiring |
It is now: https://github.com/sindresorhus/yoctocolors/releases/tag/v2.0.1 |
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.