| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e5800cc commit 6e5732e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,15 +5,15 @@ const common = require('../common.js'); | |||
| 5 | 5 | const crypto = require('crypto'); | |
| 6 | 6 | ||
| 7 | 7 | const bench = common.createBenchmark(main, { | |
| 8 | - writes: [500], | ||
| 8 | + n: [500], | ||
| 9 | 9 | algo: [ 'sha256', 'md5' ], | |
| 10 | 10 | type: ['asc', 'utf', 'buf'], | |
| 11 | 11 | out: ['hex', 'binary', 'buffer'], | |
| 12 | 12 | len: [2, 1024, 102400, 1024 * 1024], | |
| 13 | 13 | api: ['legacy', 'stream'], | |
| 14 | 14 | }); | |
| 15 | 15 | ||
| 16 | - function main({ api, type, len, out, writes, algo }) { | ||
| 16 | + function main({ api, type, len, out, n, algo }) { | ||
| 17 | 17 | if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { | |
| 18 | 18 | console.error('Crypto streams not available until v0.10'); | |
| 19 | 19 | // Use the legacy, just so that we can compare them. | |
@@ -41,15 +41,15 @@ function main({ api, type, len, out, writes, algo }) { | |||
| 41 | 41 | const fn = api === 'stream' ? streamWrite : legacyWrite; | |
| 42 | 42 | ||
| 43 | 43 | bench.start(); | |
| 44 | - fn(algo, message, encoding, writes, len, out); | ||
| 44 | + fn(algo, message, encoding, n, len, out); | ||
| 45 | 45 | } | |
| 46 | 46 | ||
| 47 | - function legacyWrite(algo, message, encoding, writes, len, outEnc) { | ||
| 48 | - const written = writes * len; | ||
| 47 | + function legacyWrite(algo, message, encoding, n, len, outEnc) { | ||
| 48 | + const written = n * len; | ||
| 49 | 49 | const bits = written * 8; | |
| 50 | 50 | const gbits = bits / (1024 * 1024 * 1024); | |
| 51 | 51 | ||
| 52 | - while (writes-- > 0) { | ||
| 52 | + while (n-- > 0) { | ||
| 53 | 53 | const h = crypto.createHash(algo); | |
| 54 | 54 | h.update(message, encoding); | |
| 55 | 55 | h.digest(outEnc); | |
@@ -58,12 +58,12 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) { | |||
| 58 | 58 | bench.end(gbits); | |
| 59 | 59 | } | |
| 60 | 60 | ||
| 61 | - function streamWrite(algo, message, encoding, writes, len, outEnc) { | ||
| 62 | - const written = writes * len; | ||
| 61 | + function streamWrite(algo, message, encoding, n, len, outEnc) { | ||
| 62 | + const written = n * len; | ||
| 63 | 63 | const bits = written * 8; | |
| 64 | 64 | const gbits = bits / (1024 * 1024 * 1024); | |
| 65 | 65 | ||
| 66 | - while (writes-- > 0) { | ||
| 66 | + while (n-- > 0) { | ||
| 67 | 67 | const h = crypto.createHash(algo); | |
| 68 | 68 | ||
| 69 | 69 | if (outEnc !== 'buffer') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,14 +5,14 @@ const common = require('../common.js'); | |||
| 5 | 5 | const crypto = require('crypto'); | |
| 6 | 6 | ||
| 7 | 7 | const bench = common.createBenchmark(main, { | |
| 8 | - writes: [500], | ||
| 8 | + n: [500], | ||
| 9 | 9 | algo: ['sha1', 'sha256', 'sha512'], | |
| 10 | 10 | type: ['asc', 'utf', 'buf'], | |
| 11 | 11 | len: [2, 1024, 102400, 1024 * 1024], | |
| 12 | 12 | api: ['legacy', 'stream'], | |
| 13 | 13 | }); | |
| 14 | 14 | ||
| 15 | - function main({ api, type, len, algo, writes }) { | ||
| 15 | + function main({ api, type, len, algo, n }) { | ||
| 16 | 16 | if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { | |
| 17 | 17 | console.error('Crypto streams not available until v0.10'); | |
| 18 | 18 | // Use the legacy, just so that we can compare them. | |
@@ -40,30 +40,30 @@ function main({ api, type, len, algo, writes }) { | |||
| 40 | 40 | const fn = api === 'stream' ? streamWrite : legacyWrite; | |
| 41 | 41 | ||
| 42 | 42 | bench.start(); | |
| 43 | - fn(algo, message, encoding, writes, len); | ||
| 43 | + fn(algo, message, encoding, n, len); | ||
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | - function legacyWrite(algo, message, encoding, writes, len) { | ||
| 47 | - const written = writes * len; | ||
| 46 | + function legacyWrite(algo, message, encoding, n, len) { | ||
| 47 | + const written = n * len; | ||
| 48 | 48 | const bits = written * 8; | |
| 49 | 49 | const gbits = bits / (1024 * 1024 * 1024); | |
| 50 | 50 | const h = crypto.createHash(algo); | |
| 51 | 51 | ||
| 52 | - while (writes-- > 0) | ||
| 52 | + while (n-- > 0) | ||
| 53 | 53 | h.update(message, encoding); | |
| 54 | 54 | ||
| 55 | 55 | h.digest(); | |
| 56 | 56 | ||
| 57 | 57 | bench.end(gbits); | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | - function streamWrite(algo, message, encoding, writes, len) { | ||
| 61 | - const written = writes * len; | ||
| 60 | + function streamWrite(algo, message, encoding, n, len) { | ||
| 61 | + const written = n * len; | ||
| 62 | 62 | const bits = written * 8; | |
| 63 | 63 | const gbits = bits / (1024 * 1024 * 1024); | |
| 64 | 64 | const h = crypto.createHash(algo); | |
| 65 | 65 | ||
| 66 | - while (writes-- > 0) | ||
| 66 | + while (n-- > 0) | ||
| 67 | 67 | h.write(message, encoding); | |
| 68 | 68 | ||
| 69 | 69 | h.end(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,28 +17,28 @@ keylen_list.forEach((key) => { | |||
| 17 | 17 | }); | |
| 18 | 18 | ||
| 19 | 19 | const bench = common.createBenchmark(main, { | |
| 20 | - writes: [500], | ||
| 20 | + n: [500], | ||
| 21 | 21 | algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'], | |
| 22 | 22 | keylen: keylen_list, | |
| 23 | 23 | len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024], | |
| 24 | 24 | }); | |
| 25 | 25 | ||
| 26 | - function main({ len, algo, keylen, writes }) { | ||
| 26 | + function main({ len, algo, keylen, n }) { | ||
| 27 | 27 | const message = Buffer.alloc(len, 'b'); | |
| 28 | 28 | bench.start(); | |
| 29 | - StreamWrite(algo, keylen, message, writes, len); | ||
| 29 | + StreamWrite(algo, keylen, message, n, len); | ||
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | - function StreamWrite(algo, keylen, message, writes, len) { | ||
| 33 | - const written = writes * len; | ||
| 32 | + function StreamWrite(algo, keylen, message, n, len) { | ||
| 33 | + const written = n * len; | ||
| 34 | 34 | const bits = written * 8; | |
| 35 | 35 | const kbits = bits / (1024); | |
| 36 | 36 | ||
| 37 | 37 | const privateKey = RSA_PrivatePem[keylen]; | |
| 38 | 38 | const s = crypto.createSign(algo); | |
| 39 | 39 | const v = crypto.createVerify(algo); | |
| 40 | 40 | ||
| 41 | - while (writes-- > 0) { | ||
| 41 | + while (n-- > 0) { | ||
| 42 | 42 | s.update(message); | |
| 43 | 43 | v.update(message); | |
| 44 | 44 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ const common = require('../common.js'); | |||
| 5 | 5 | const dgram = require('dgram'); | |
| 6 | 6 | const PORT = common.PORT; | |
| 7 | 7 | ||
| 8 | - // `num` is the number of send requests to queue up each time. | ||
| 8 | + // `n` is the number of send requests to queue up each time. | ||
| 9 | 9 | // Keep it reasonably high (>10) otherwise you're benchmarking the speed of | |
| 10 | 10 | // event loop cycles more than anything else. | |
| 11 | 11 | const bench = common.createBenchmark(main, { | |
@@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, { | |||
| 15 | 15 | dur: [5], | |
| 16 | 16 | }); | |
| 17 | 17 | ||
| 18 | - function main({ dur, len, num: n, type }) { | ||
| 18 | + function main({ dur, len, n, type }) { | ||
| 19 | 19 | const chunk = Buffer.allocUnsafe(len); | |
| 20 | 20 | let sent = 0; | |
| 21 | 21 | let received = 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments