UNPKG

488 BJavaScriptView Raw
1
2const mqtt = require('../')
3const parser = mqtt.parser()
4const max = 10000000
5let i
6const start = Date.now() / 1000
7
8for (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
17const time = Date.now() / 1000 - start
18console.log('Total packets', max)
19console.log('Total time', Math.round(time * 100) / 100)
20console.log('Packet/s', max / time)