Skip to content

Commit fdfab65

Browse files
authored
Add node:util.styleText to benchmark (#109)
1 parent 0928e67 commit fdfab65

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

bench/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ import kleur from "kleur"
66
import colors from "colors"
77
import picocolors from "picocolors"
88
import ansicolors from "ansi-colors"
9+
import { styleText } from "node:util"
910

1011
const test = (c) =>
1112
c.red(`${c.bold(`${c.cyan(`${c.yellow("yellow")}cyan`)}`)}red`)
1213

14+
const testNode = () =>
15+
styleText("red", `${styleText(["bold", "cyan"], `${styleText("yellow", "yellow")}cyan`)}red`)
16+
1317
new bench.Suite()
14-
.add(" chalk ", () => test(chalk))
15-
.add(" kleur ", () => test(kleur))
16-
.add(" colors ", () => test(colors))
17-
.add(" ansi-colors ", () => test(ansicolors))
18-
.add(" picocolors ", () => test(picocolors))
19-
.add("+ colorette ", () => test(colorette))
18+
.add(" chalk ", () => test(chalk))
19+
.add(" kleur ", () => test(kleur))
20+
.add(" colors ", () => test(colors))
21+
.add(" ansi-colors ", () => test(ansicolors))
22+
.add(" picocolors ", () => test(picocolors))
23+
.add(" node:util.styleText ", () => testNode())
24+
.add("+ colorette ", () => test(colorette))
2025
.on("cycle", ({ target: { name, hz } }) =>
2126
console.log(name, `${Math.floor(hz).toLocaleString()} ops/sec`.padStart(18))
2227
)

0 commit comments

Comments
 (0)