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 text-encoder benchmark · nodejs/node@fcf6188

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 clipboard
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
5+
const BASE = 'string\ud801';
6+
7+
const bench = common.createBenchmark(main, {
8+
len: [256, 1024, 1024 * 32],
9+
n: [1e4],
10+
op: ['encode', 'encodeInto']
11+
});
12+
13+
function main({ n, op, len }) {
14+
const encoder = new TextEncoder();
15+
const input = BASE.repeat(len);
16+
const subarray = new Uint8Array(len);
17+
18+
bench.start();
19+
switch (op) {
20+
case 'encode': {
21+
for (let i = 0; i < n; i++)
22+
encoder.encode(input);
23+
break;
24+
}
25+
case 'encodeInto': {
26+
for (let i = 0; i < n; i++)
27+
encoder.encodeInto(input, subarray);
28+
break;
29+
}
30+
}
31+
bench.end(n);
32+
}

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.