1 |
|
2 | const mqtt = require('../')
|
3 | const parser = mqtt.parser()
|
4 | const max = 10000000
|
5 | let i
|
6 | const start = Date.now() / 1000
|
7 |
|
8 | for (i = 0; i < max; i++) {
|
9 | parser.parse(Buffer.from([
|
10 | 48, 10, // Header (publish)
|
11 | 0, 4, // Topic length
|
12 | 116, 101, 115, 116, // Topic (test)
|
13 | 116, 101, 115, 116 // Payload (test)
|
14 | ]))
|
15 | }
|
16 |
|
17 | const time = Date.now() / 1000 - start
|
18 | console.log('Total packets', max)
|
19 | console.log('Total time', Math.round(time * 100) / 100)
|
20 | console.log('Packet/s', max / time)
|