Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
Add kleur/colors and update colorette in benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Sep 21, 2021
1 parent 6c84ef0 commit 56430e3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
22 changes: 12 additions & 10 deletions README.md
Expand Up @@ -36,22 +36,24 @@ Function calling time:

```
$ ./test/benchmark.js
chalk 8,142,778 ops/sec
ansi-colors 2,626,780 ops/sec
kleur 11,299,102 ops/sec
colorette 14,852,996 ops/sec
nanocolors 14,897,991 ops/sec
chalk 11,680,127 ops/sec
ansi-colors 3,654,108 ops/sec
kleur 15,857,360 ops/sec
kleur/colors 22,195,173 ops/sec
colorette 20,630,562 ops/sec
nanocolors 20,681,984 ops/sec
```

Library loading time:

```
$ ./test/loading.js
chalk 6.163 ms
ansi-colors 1.603 ms
kleur 1.771 ms
colorette 0.848 ms
nanocolors 0.571 ms
chalk 3.436 ms
ansi-colors 1.083 ms
kleur 1.167 ms
kleur/colors 0.442 ms
colorette 2.061 ms
nanocolors 0.402 ms
```

The space in `node_modules` including sub-dependencies:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -38,7 +38,7 @@
"benchmark": "^2.1.4",
"chalk": "^4.1.2",
"clean-publish": "^2.2.0",
"colorette": "^2.0.2",
"colorette": "^2.0.4",
"dual-publish": "^1.0.9",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
Expand Down
6 changes: 5 additions & 1 deletion test/benchmark.js
Expand Up @@ -3,6 +3,7 @@
let benchmark = require('benchmark')
let colorette = require('colorette')
let kleur = require('kleur')
let kleurColors = require('kleur/colors')
let chalk = require('chalk')
let ansi = require('ansi-colors')

Expand All @@ -26,14 +27,17 @@ suite
.add('kleur', () => {
kleur.red(kleur.bold('bold') + ' red')
})
.add('kleur/colors', () => {
kleurColors.red(kleurColors.bold('bold') + ' red')
})
.add('colorette', () => {
colorette.red(colorette.bold('bold') + ' red')
})
.add('nanocolors', () => {
nanocolors.red(nanocolors.bold('bold') + ' red')
})
.on('cycle', event => {
let name = event.target.name.padEnd('ansi-colors '.length)
let name = event.target.name.padEnd('kleur/colors '.length)
let hz = formatNumber(event.target.hz.toFixed(0)).padStart(10)
process.stdout.write(`${name}${nanocolors.bold(hz)} ops/sec\n`)
})
Expand Down
6 changes: 5 additions & 1 deletion test/loading.js
Expand Up @@ -4,7 +4,7 @@ let before
function showTime(name) {
let after = performance.now()
let time = (Math.round(1000 * (after - before)) / 1000).toString()
let title = name.padEnd('ansi-colors '.length)
let title = name.padEnd('kleur/colors '.length)
process.stdout.write(title + '\x1B[1m' + time.padEnd(5) + '\x1B[22m ms\n')
}

Expand All @@ -20,6 +20,10 @@ before = performance.now()
let kleur = require('kleur')
showTime('kleur')

before = performance.now()
let kleurColors = require('kleur/colors')
showTime('kleur/colors')

before = performance.now()
let colorette = require('colorette')
showTime('colorette')
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Expand Up @@ -1795,10 +1795,10 @@ colorette@^1.2.2, colorette@^1.3.0, colorette@^1.4.0:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40"
integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==

colorette@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.2.tgz#f04cbc7f59ffc4f33ba4da0702dd4c8a68885d91"
integrity sha512-iO5Ycn8HKVhTGGKpwJtyzrrvOGI9YC4u4dppP5yKSGP47ApaZNwX7ne4PtgpTzq+JBwQh6FrdAfCSYTBQe1+FA==
colorette@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.4.tgz#d3f3e81ec242623cb103adfb75fcd192d1559b5e"
integrity sha512-mw9BGVqQa4f0jnWK5SGce3XA5qRklGBSkX9Ka6EBkPA3P8zPX/QC9BlLI803b8Jy27qA9HpUxhy1GxYTID1xYA==

combined-stream@^1.0.8:
version "1.0.8"
Expand Down Expand Up @@ -4731,9 +4731,9 @@ nan@^2.12.1:
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==

nanocolors@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/nanocolors/-/nanocolors-0.1.1.tgz#1b148b06c6279084709675fb3d699e0cdc668114"
integrity sha512-9XCSSmaAkJVops0tOTkt1lUXO8iO7vTYr1X45I8kCbgP2cMS9RvPGVnp/Ou+ISsm9JhKpKCON7zwOFyWcWrzhA==
version "0.1.2"
resolved "https://registry.yarnpkg.com/nanocolors/-/nanocolors-0.1.2.tgz#5ab92baf387c9d0d68feb3ce798f235882671faf"
integrity sha512-uOh+wwz+9+MWa4W7emZcvz9tNlGrkNR9RmnZnbvJG95OsXeWJwqUyYKvDvA3bJHnEW2CTdOCV92DTMBCqyweJg==

nanoid@^3.1.23, nanoid@^3.1.25:
version "3.1.25"
Expand Down

0 comments on commit 56430e3

Please sign in to comment.