Skip to content

Instantly share code, notes, and snippets.

@RafaelGSS
Created March 7, 2024 13:13
Show Gist options
  • Save RafaelGSS/b46c6c562090c9e291f5451487ffc652 to your computer and use it in GitHub Desktop.
Save RafaelGSS/b46c6c562090c9e291f5451487ffc652 to your computer and use it in GitHub Desktop.
util.styleText benchmark against alternatives
$ git rev-parse HEAD
e3743b744abb5c8d39d0b722fbbdb7538df16c01
$ node bench/style-text.mjs

https://github.com/RafaelGSS/nodejs-bench-operations/commit/e3743b744abb5c8d39d0b722fbbdb7538df16c01

Style text

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

Style text

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

Style text

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

Considerations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment