$ git rev-parse HEAD
e3743b744abb5c8d39d0b722fbbdb7538df16c01
$ node bench/style-text.mjs
name | ops/sec | samples |
---|---|---|
util.styleText(red, hello world) | 95,930,666 | 103 |
chalk.red(hello world) | 79,477,726 | 103 |
ansiColors.red(hello world) | 15,539,747 | 98 |
colorette.red(hello world) | 107,898,472 | 97 |
picocolors.red(hello world) | 110,523,068 | 100 |
$ node bench/style-text.mjs
name | ops/sec | samples |
---|---|---|
util.styleText(red, hello world) | 97,092,283 | 97 |
chalk.red(hello world) | 78,621,268 | 97 |
ansiColors.red(hello world) | 15,678,424 | 92 |
colorette.red(hello world) | 111,241,311 | 97 |
picocolors.red(hello world) | 110,319,624 | 102 |
$ node bench/style-text.mjs
name | ops/sec | samples |
---|---|---|
util.styleText(red, hello world) | 100,677,496 | 101 |
chalk.red(hello world) | 81,411,842 | 101 |
ansiColors.red(hello world) | 15,721,638 | 96 |
colorette.red(hello world) | 110,484,381 | 99 |
picocolors.red(hello world) | 110,202,768 | 97 |
➜ nodejs-bench-operations git:(style-text-bench) node -v
v21.7.0
- This gist refers to https://twitter.com/kibertoad/status/1765525939121803560
- I suspect the results from https://github.com/BeeeQueue/node-cli-colors-benchmark?tab=readme-ov-file#results are not realistic, as most of the libraries perform a check if the TTY is available to output before getting creating the string.
- I didn't run my benchmark in a dedicated machine (due to limited bandwidth), but the results seems consistent on my OSX M2.
- It is also important to mention that two different benchmark tools were used and may be responsible for the results presented.