(n, data, method)
| 33 | } |
| 34 | |
| 35 | function measureSubtle(n, data, method) { |
| 36 | const ec = new TextEncoder(); |
| 37 | data = ec.encode(data); |
| 38 | const jobs = new Array(n); |
| 39 | bench.start(); |
| 40 | for (let i = 0; i < n; i++) |
| 41 | jobs[i] = subtle.digest(method, data); |
| 42 | Promise.all(jobs).then(() => bench.end(n)).catch((err) => { |
| 43 | process.nextTick(() => { throw err; }); |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | function main({ n, sync, data, method }) { |
| 48 | data = globalThis.crypto.getRandomValues(Buffer.alloc(data)); |