Skip to content

Commit d84be84

Browse files
RafaelGSSmarco-ippolito
authored andcommitted
benchmark: add validateStream to styleText bench
PR-URL: #56556 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 03878b0 commit d84be84

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
constcommon=require('../common.js');
44

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

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

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

3032
bench.start();
3133
for(leti=0;i<n;i++){
34+
letcolored='';
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)