(n, op, key, keys, ciphertexts)
| 84 | } |
| 85 | |
| 86 | function measureAsync(n, op, key, keys, ciphertexts) { |
| 87 | let remaining = n; |
| 88 | function done() { |
| 89 | if (--remaining === 0) |
| 90 | bench.end(n); |
| 91 | else |
| 92 | one(); |
| 93 | } |
| 94 | |
| 95 | function one() { |
| 96 | const k = key || keys[n - remaining]; |
| 97 | if (op === 'encapsulate') { |
| 98 | crypto.encapsulate(k, done); |
| 99 | } else { |
| 100 | crypto.decapsulate(k, ciphertexts[n - remaining], done); |
| 101 | } |
| 102 | } |
| 103 | bench.start(); |
| 104 | one(); |
| 105 | } |
| 106 | |
| 107 | function measureAsyncParallel(n, op, key, keys, ciphertexts) { |
| 108 | let remaining = n; |