| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c161635 commit 44d7b92
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,18 +5,18 @@ 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, { | |
| 12 | - len: [64, 256, 512, 1024], | ||
| 13 | - num: [100], | ||
| 14 | - chunks: [1, 2, 4, 8], | ||
| 12 | + len: [64, 512, 1024], | ||
| 13 | + n: [100], | ||
| 14 | + chunks: [1, 4], | ||
| 15 | 15 | type: ['concat', 'multi'], | |
| 16 | 16 | dur: [5], | |
| 17 | 17 | }); | |
| 18 | 18 | ||
| 19 | - function main({ dur, len, num, type, chunks }) { | ||
| 19 | + function main({ dur, len, n, type, chunks }) { | ||
| 20 | 20 | const chunk = []; | |
| 21 | 21 | for (let i = 0; i < chunks; i++) { | |
| 22 | 22 | chunk.push(Buffer.allocUnsafe(Math.round(len / chunks))); | |
@@ -28,23 +28,23 @@ function main({ dur, len, num, type, chunks }) { | |||
| 28 | 28 | const onsend = type === 'concat' ? onsendConcat : onsendMulti; | |
| 29 | 29 | ||
| 30 | 30 | function onsendConcat() { | |
| 31 | - if (sent++ % num === 0) { | ||
| 31 | + if (sent++ % n === 0) { | ||
| 32 | 32 | // The setImmediate() is necessary to have event loop progress on OSes | |
| 33 | 33 | // that only perform synchronous I/O on nonblocking UDP sockets. | |
| 34 | 34 | setImmediate(() => { | |
| 35 | - for (let i = 0; i < num; i++) { | ||
| 35 | + for (let i = 0; i < n; i++) { | ||
| 36 | 36 | socket.send(Buffer.concat(chunk), PORT, '127.0.0.1', onsend); | |
| 37 | 37 | } | |
| 38 | 38 | }); | |
| 39 | 39 | } | |
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | 42 | function onsendMulti() { | |
| 43 | - if (sent++ % num === 0) { | ||
| 43 | + if (sent++ % n === 0) { | ||
| 44 | 44 | // The setImmediate() is necessary to have event loop progress on OSes | |
| 45 | 45 | // that only perform synchronous I/O on nonblocking UDP sockets. | |
| 46 | 46 | setImmediate(() => { | |
| 47 | - for (let i = 0; i < num; i++) { | ||
| 47 | + for (let i = 0; i < n; i++) { | ||
| 48 | 48 | socket.send(chunk, PORT, '127.0.0.1', onsend); | |
| 49 | 49 | } | |
| 50 | 50 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments