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

Function main

benchmark/crypto/hash-stream-throughput.js:15–44  ·  view source on GitHub ↗
({ api, type, len, algo, n })

Source from the content-addressed store, hash-verified

13});
14
15function main({ api, type, len, algo, n }) {
16 if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) {
17 console.error('Crypto streams not available until v0.10');
18 // Use the legacy, just so that we can compare them.
19 api = 'legacy';
20 }
21
22 let message;
23 let encoding;
24 switch (type) {
25 case 'asc':
26 message = 'a'.repeat(len);
27 encoding = 'ascii';
28 break;
29 case 'utf':
30 message = 'ü'.repeat(len / 2);
31 encoding = 'utf8';
32 break;
33 case 'buf':
34 message = Buffer.alloc(len, 'b');
35 break;
36 default:
37 throw new Error(`unknown message type: ${type}`);
38 }
39
40 const fn = api === 'stream' ? streamWrite : legacyWrite;
41
42 bench.start();
43 fn(algo, message, encoding, n, len);
44}
45
46function legacyWrite(algo, message, encoding, n, len) {
47 const written = n * len;

Callers

nothing calls this directly

Calls 5

allocMethod · 0.80
fnFunction · 0.50
testMethod · 0.45
errorMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…