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 variety of inputs to text-encoder · nodejs/node@9925d20

File tree

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

‎benchmark/util/text-encoder.js‎

Copy file name to clipboardExpand all lines: benchmark/util/text-encoder.js
+18-5Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@
22

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

5-
const BASE = 'string\ud801';
6-
75
const bench = common.createBenchmark(main, {
8-
len: [256, 1024, 1024 * 32],
6+
len: [16, 32, 256, 1024, 1024 * 32],
97
n: [1e4],
8+
type: ['one-byte-string', 'two-byte-string', 'ascii'],
109
op: ['encode', 'encodeInto']
1110
});
1211

13-
function main({ n, op, len }) {
12+
function main({ n, op, len, type }) {
1413
const encoder = new TextEncoder();
15-
const input = BASE.repeat(len);
14+
let base = '';
15+
16+
switch (type) {
17+
case 'ascii':
18+
base = 'a';
19+
break;
20+
case 'one-byte-string':
21+
base = '\xff';
22+
break;
23+
case 'two-byte-string':
24+
base = 'ğ';
25+
break;
26+
}
27+
28+
const input = base.repeat(len);
1629
const subarray = new Uint8Array(len);
1730

1831
bench.start();

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.