| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,38 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common.js'); | ||
| 4 | + const dgram = require('dgram'); | ||
| 5 | + | ||
| 6 | + const configs = { | ||
| 7 | + n: [1e4], | ||
| 8 | + port: ['true', 'false'], | ||
| 9 | + address: ['true', 'false'], | ||
| 10 | + }; | ||
| 11 | + | ||
| 12 | + const bench = common.createBenchmark(main, configs); | ||
| 13 | + | ||
| 14 | + function main(conf) { | ||
| 15 | + const n = +conf.n; | ||
| 16 | + const port = conf.port === 'true' ? 0 : undefined; | ||
| 17 | + const address = conf.address === 'true' ? '0.0.0.0' : undefined; | ||
| 18 | + | ||
| 19 | + if (port !== undefined && address !== undefined) { | ||
| 20 | + bench.start(); | ||
| 21 | + for (let i = 0; i < n; i++) { | ||
| 22 | + dgram.createSocket('udp4').bind(port, address).unref(); | ||
| 23 | + } | ||
| 24 | + bench.end(n); | ||
| 25 | + } else if (port !== undefined) { | ||
| 26 | + bench.start(); | ||
| 27 | + for (let i = 0; i < n; i++) { | ||
| 28 | + dgram.createSocket('udp4').bind(port).unref(); | ||
| 29 | + } | ||
| 30 | + bench.end(n); | ||
| 31 | + } else if (port === undefined && address === undefined) { | ||
| 32 | + bench.start(); | ||
| 33 | + for (let i = 0; i < n; i++) { | ||
| 34 | + dgram.createSocket('udp4').bind().unref(); | ||
| 35 | + } | ||
| 36 | + bench.end(n); | ||
| 37 | + } | ||
| 38 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments