MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/util/text-decoder-stream.js:19–55  ·  view source on GitHub ↗
({ encoding, len, unicode, chunks, n, ignoreBOM, type, fatal })

Source from the content-addressed store, hash-verified

17const ASCII_ALPHA = 'Blueberry jam';
18
19function main({ encoding, len, unicode, chunks, n, ignoreBOM, type, fatal }) {
20 const decoder = new TextDecoder(encoding, { ignoreBOM, fatal });
21 let buf;
22
23 const fill = Buffer.from(unicode ? UNICODE_ALPHA : ASCII_ALPHA, encoding);
24
25 switch (type) {
26 case 'SharedArrayBuffer': {
27 buf = new SharedArrayBuffer(len);
28 Buffer.from(buf).fill(fill);
29 break;
30 }
31 case 'ArrayBuffer': {
32 buf = new ArrayBuffer(len);
33 Buffer.from(buf).fill(fill);
34 break;
35 }
36 case 'Buffer': {
37 buf = Buffer.alloc(len, fill);
38 break;
39 }
40 }
41
42 const chunk = Math.ceil(len / chunks);
43 const max = len - chunk;
44 bench.start();
45 for (let i = 0; i < n; i++) {
46 let pos = 0;
47 while (pos < max) {
48 decoder.decode(buf.slice(pos, pos + chunk), { stream: true });
49 pos += chunk;
50 }
51
52 decoder.decode(buf.slice(pos));
53 }
54 bench.end(n);
55}

Callers

nothing calls this directly

Calls 7

decodeMethod · 0.95
fillMethod · 0.80
allocMethod · 0.80
sliceMethod · 0.65
fromMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…