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

Function main

benchmark/crypto/hmac-throughput.js:17–41  ·  view source on GitHub ↗
({ api, type, len, algo, keylen, n })

Source from the content-addressed store, hash-verified

15});
16
17function main({ api, type, len, algo, keylen, n }) {
18 let message;
19 let encoding;
20 switch (type) {
21 case 'asc':
22 message = 'a'.repeat(len);
23 encoding = 'ascii';
24 break;
25 case 'utf':
26 message = '\u00fc'.repeat(len / 2);
27 encoding = 'utf8';
28 break;
29 case 'buf':
30 message = Buffer.alloc(len, 'b');
31 break;
32 default:
33 throw new Error(`unknown message type: ${type}`);
34 }
35
36 const fn = api === 'stream' ? streamWrite : updateDigest;
37 const key = Buffer.alloc(keylen, 'k');
38
39 bench.start();
40 fn(algo, key, message, encoding, n, len);
41}
42
43function updateDigest(algo, key, message, encoding, n, len) {
44 const written = n * len;

Callers

nothing calls this directly

Calls 3

allocMethod · 0.80
fnFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…