Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ithinuel/mqttsn-packet
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinuel committed Nov 20, 2015
2 parents d4dd4a5 + 274ff99 commit 4162c10
Show file tree
Hide file tree
Showing 7 changed files with 520 additions and 534 deletions.
22 changes: 22 additions & 0 deletions benchmark/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

var mqttsn = require('../'),
max = 100000,
i,
start = Date.now(),
time,
buf = new Buffer('test'),
object = {
cmd: 'publish',
topicIdType: 'normal',
topicId: 295,
payload: buf
};

for (i = 0; i < max; i += 1) {
mqttsn.generate(object);
}

time = Date.now() - start;
console.log('Total time', time);
console.log('Total packets', max);
console.log('Packet/s', max / time * 1000);
21 changes: 21 additions & 0 deletions benchmark/parse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var mqttsn = require('../'),
parser = mqttsn.parser(),
max = 10000000,
i,
start = Date.now(),
time,
buf = new Buffer([
18, 4, // header
12, 1, // flags & protocolId
14, 16, // duration
116, 101, 115, 116, 67, 108, 105, 101, 110, 116, 73, 100
]);

for (i = 0; i < max; i += 1) {
parser.parse(buf);
}

time = Date.now() - start;
console.log('Total time', time);
console.log('Total packets', max);
console.log('Packet/s', max / time * 1000);
Loading

0 comments on commit 4162c10

Please sign in to comment.