({ n, subscribers, checkSubscribers, objSize })
| 25 | } |
| 26 | |
| 27 | function main({ n, subscribers, checkSubscribers, objSize }) { |
| 28 | const channel = dc.channel('test'); |
| 29 | for (let i = 0; i < subscribers; i++) { |
| 30 | channel.subscribe(noop); |
| 31 | } |
| 32 | |
| 33 | const publishWithCheck = () => { |
| 34 | const data = createObj(objSize); |
| 35 | bench.start(); |
| 36 | for (let i = 0; i < n; i++) { |
| 37 | if (channel.hasSubscribers) { |
| 38 | channel.publish(data); |
| 39 | } |
| 40 | } |
| 41 | bench.end(n); |
| 42 | }; |
| 43 | |
| 44 | const publishWithoutCheck = () => { |
| 45 | const data = createObj(objSize); |
| 46 | bench.start(); |
| 47 | for (let i = 0; i < n; i++) { |
| 48 | channel.publish(data); |
| 49 | } |
| 50 | bench.end(n); |
| 51 | }; |
| 52 | |
| 53 | if (checkSubscribers) { |
| 54 | publishWithCheck(); |
| 55 | } else { |
| 56 | publishWithoutCheck(); |
| 57 | } |
| 58 | } |
nothing calls this directly
no test coverage detected