Skip to content

Commit bf4a28d

Browse files
committed
fixup! util: add fast path to stripVTControlCharacters
1 parent 3929fc3 commit bf4a28d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

benchmark/util/strip-vt-control-characters.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@ const { stripVTControlCharacters } = require('node:util');
66
const assert = require('node:assert');
77

88
const bench = common.createBenchmark(main, {
9-
input: ['plain-short', 'plain-long', 'ansi-short', 'ansi-heavy'],
9+
input: ['noAnsi-short', 'noAnsi-long', 'ansi-short', 'ansi-long'],
1010
n: [1e6],
1111
});
1212

1313
function main({ input, n }) {
1414
let str;
1515
switch (input) {
16-
case 'plain-short':
17-
str = 'Hello, World!';
16+
case 'noAnsi-short':
17+
str = 'This is a plain text string without any ANSI codes';
1818
break;
19-
case 'plain-long':
20-
str = 'a'.repeat(1000);
19+
case 'noAnsi-long':
20+
str = 'Long plain text without ANSI. '.repeat(100);
2121
break;
2222
case 'ansi-short':
2323
str = '\u001B[31mHello\u001B[39m';
2424
break;
25-
case 'ansi-heavy':
26-
str = '\u001B[1m\u001B[31m\u001B[4m' + 'x'.repeat(100) +
27-
'\u001B[24m\u001B[39m\u001B[22m';
25+
case 'ansi-long':
26+
str = ('\u001B[31m' + 'colored text '.repeat(10) + '\u001B[39m').repeat(10);
2827
break;
2928
}
3029

0 commit comments

Comments
 (0)