Skip to content

Commit 4aa1afd

Browse files
RafaelGSSaduh95
authored andcommitted
benchmark: add validateStream to styleText bench
PR-URL: #56556 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent c2d5a0c commit 4aa1afd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

benchmark/util/style-text.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
const common = require('../common.js');
44

55
const { styleText } = require('node:util');
6+
const assert = require('node:assert');
67

78
const bench = common.createBenchmark(main, {
89
messageType: ['string', 'number', 'boolean', 'invalid'],
910
format: ['red', 'italic', 'invalid'],
11+
validateStream: [1, 0],
1012
n: [1e3],
1113
});
1214

13-
function main({ messageType, format, n }) {
15+
function main({ messageType, format, validateStream, n }) {
1416
let str;
1517
switch (messageType) {
1618
case 'string':
@@ -29,8 +31,10 @@ function main({ messageType, format, n }) {
2931

3032
bench.start();
3133
for (let i = 0; i < n; i++) {
34+
let colored = '';
3235
try {
33-
styleText(format, str);
36+
colored = styleText(format, str, { validateStream });
37+
assert.ok(colored); // Attempt to avoid dead-code elimination
3438
} catch {
3539
// eslint-disable no-empty
3640
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy