Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: add validateStream to styleText bench #56556

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions benchmark/util/style-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

const common = require('../common.js');

const { styleText } = require('node:util');

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

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'styleText' is assigned a value but never used

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 @@

bench.start();
for (let i = 0; i < n; i++) {
let colored = '';
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
Loading