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

Function main

benchmark/crypto/oneshot-hash.js:21–42  ·  view source on GitHub ↗
({ length, type, method, n })

Source from the content-addressed store, hash-verified

19});
20
21function main({ length, type, method, n }) {
22 let data = fs.readFileSync(filepath);
23 if (type === 'string') {
24 data = data.toString().slice(0, length);
25 } else {
26 data = Uint8Array.prototype.slice.call(data, 0, length);
27 }
28
29 const oneshotHash = hash ?
30 (method, input) => hash(method, input, 'hex') :
31 (method, input) => createHash(method).update(input).digest('hex');
32 const array = [];
33 for (let i = 0; i < n; i++) {
34 array.push(null);
35 }
36 bench.start();
37 for (let i = 0; i < n; i++) {
38 array[i] = oneshotHash(method, data);
39 }
40 bench.end(n);
41 assert.strictEqual(typeof array[n - 1], 'string');
42}

Callers

nothing calls this directly

Calls 10

createHashFunction · 0.85
sliceMethod · 0.65
updateMethod · 0.65
hashFunction · 0.50
readFileSyncMethod · 0.45
toStringMethod · 0.45
callMethod · 0.45
pushMethod · 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…