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