Skip to content

Commit 23812f5

Browse files
committed
benchmark: add validateStream to styleText bench
1 parent 649da3b commit 23812f5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

benchmark/util/style-text.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ const { styleText } = require('node:util');
77
const bench = common.createBenchmark(main, {
88
messageType: ['string', 'number', 'boolean', 'invalid'],
99
format: ['red', 'italic', 'invalid'],
10+
validateStream: [1, 0],
1011
n: [1e3],
1112
});
1213

13-
function main({ messageType, format, n }) {
14+
function main({ messageType, format, validateStream, n }) {
1415
let str;
1516
switch (messageType) {
1617
case 'string':
@@ -29,8 +30,10 @@ function main({ messageType, format, n }) {
2930

3031
bench.start();
3132
for (let i = 0; i < n; i++) {
33+
let colored = ''
3234
try {
33-
styleText(format, str);
35+
colored = util.styleText(format, str, { validateStream });
36+
assert.ok(colored); // Attempt to avoid dead-code elimination
3437
} catch {
3538
// eslint-disable no-empty
3639
}

0 commit comments

Comments
 (0)