| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,28 +5,28 @@ 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 | 12 | len: [1, 64, 256, 1024], | |
| 13 | - num: [100], | ||
| 13 | + n: [100], | ||
| 14 | 14 | type: ['send', 'recv'], | |
| 15 | 15 | dur: [5], | |
| 16 | 16 | }); | |
| 17 | 17 | ||
| 18 | - function main({ dur, len, num, 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; | |
| 22 | 22 | const socket = dgram.createSocket('udp4'); | |
| 23 | 23 | ||
| 24 | 24 | function onsend() { | |
| 25 | - if (sent++ % num === 0) { | ||
| 25 | + if (sent++ % n === 0) { | ||
| 26 | 26 | // The setImmediate() is necessary to have event loop progress on OSes | |
| 27 | 27 | // that only perform synchronous I/O on nonblocking UDP sockets. | |
| 28 | 28 | setImmediate(() => { | |
| 29 | - for (let i = 0; i < num; i++) { | ||
| 29 | + for (let i = 0; i < n; i++) { | ||
| 30 | 30 | socket.send(chunk, 0, chunk.length, PORT, '127.0.0.1', onsend); | |
| 31 | 31 | } | |
| 32 | 32 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments