Skip to content

Commit

Permalink
Add memory stats to aedes bench programs
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Aug 9, 2017
1 parent 5e96af0 commit 1a8f90e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions aedes/bench/README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Run these programs with:

node file.js
node --expose-gc file.js

and compare the timings printed to standard output.
and compare the figures printed to standard output.
16 changes: 13 additions & 3 deletions aedes/bench/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ var QlobberOpts = {

function time(f, matcher, arg)
{
var start = new Date();
var start_time = new Date();
f(matcher, arg);
var end = new Date();
console.log(f.name + ':', end.getTime() - start.getTime());
var end_time = new Date();
console.log(f.name + ':', (end_time.getTime() - start_time.getTime()) + 'ms');
}

function add_to_qlobber(matcher, add)
Expand Down Expand Up @@ -60,12 +60,22 @@ function match_public_topics(matcher, match)

function times(QlobberClass, add, remove, match)
{
gc();
var start_mem = process.memoryUsage();

var matcher = new QlobberClass(QlobberOpts);
time(add_to_qlobber, matcher, add);
time(add_to_qlobber, matcher, add);
time(remove_from_qlobber, matcher, remove);
time(match_client_topics, matcher, match);
time(match_public_topics, matcher, match);

gc();
var end_mem = process.memoryUsage();

console.log(
'heap:', ((end_mem.heapUsed - start_mem.heapUsed) / 1024 / 1024).toFixed(1) + 'MiB',
'rss:', ((end_mem.rss - start_mem.rss) / 1024 / 1024).toFixed(1) + 'MiB');
}

module.exports = times;

0 comments on commit 1a8f90e

Please sign in to comment.