Skip to content

Commit

Permalink
benchmark: add validateStream to styleText bench
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Jan 10, 2025
1 parent 649da3b commit 23812f5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions benchmark/util/style-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const { styleText } = require('node:util');
const bench = common.createBenchmark(main, {
messageType: ['string', 'number', 'boolean', 'invalid'],
format: ['red', 'italic', 'invalid'],
validateStream: [1, 0],
n: [1e3],
});

function main({ messageType, format, n }) {
function main({ messageType, format, validateStream, n }) {
let str;
switch (messageType) {
case 'string':
Expand All @@ -29,8 +30,10 @@ function main({ messageType, format, n }) {

bench.start();
for (let i = 0; i < n; i++) {
let colored = ''

Check failure on line 33 in benchmark/util/style-text.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
try {
styleText(format, str);
colored = util.styleText(format, str, { validateStream });

Check failure on line 35 in benchmark/util/style-text.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'util' is not defined
assert.ok(colored); // Attempt to avoid dead-code elimination

Check failure on line 36 in benchmark/util/style-text.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'assert' is not defined
} catch {
// eslint-disable no-empty
}
Expand Down

0 comments on commit 23812f5

Please sign in to comment.