GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: add validateStream to styleText bench · nodejs/node@4aa1afd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/util
    • style-text.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/util/style-text.js‎

Copy file name to clipboardExpand all lines: benchmark/util/style-text.js
+6-2Lines 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 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.