UNPKG

450 BJavaScriptView Raw
1const mqtt = require('../')
2const max = 100000
3let i
4const buf = Buffer.from('test')
5
6// initialize it
7mqtt.generate({
8 cmd: 'publish',
9 topic: 'test',
10 payload: buf
11})
12
13const start = Date.now()
14
15for (i = 0; i < max; i++) {
16 mqtt.generate({
17 cmd: 'publish',
18 topic: 'test',
19 payload: buf
20 })
21}
22
23const time = Date.now() - start
24console.log('Total time', time)
25console.log('Total packets', max)
26console.log('Packet/s', max / time * 1000)