Permalink
Browse files

adds duraion flag to benchmarks

  • Loading branch information...
1 parent b85fe89 commit 6669081683c7fbaf3c1f56c1a56b42888ad0de59 @gjohnson gjohnson committed Dec 28, 2012
Showing with 12 additions and 5 deletions.
  1. +3 −2 Makefile
  2. +3 −1 benchmark/pub.js
  3. +6 −2 benchmark/sub.js
View
@@ -2,10 +2,11 @@
TESTS = $(wildcard test/test.*.js)
PER_TICK=1000
SIZE=1024
+DURATION=5000
bm:
- node benchmark/pub --size $(SIZE) --per-tick $(PER_TICK) &
- node benchmark/sub --size $(SIZE)
+ node benchmark/pub --size $(SIZE) --per-tick $(PER_TICK) --duration $(DURATION) &
+ node benchmark/sub --size $(SIZE) --duration $(DURATION)
test:
@./test/run $(TESTS)
View
@@ -6,10 +6,12 @@ program
.option('-T, --type <name>', 'socket type [pub]', 'pub')
.option('-t, --per-tick <n>', 'messages per tick [1000]', parseInt)
.option('-s, --size <n>', 'message size in bytes [1024]', parseInt)
+ .option('-d, --duration <n>', 'duration of test [5000]', parseInt)
.parse(process.argv)
var sock = ss.socket(program.type);
sock.bind(3000);
+sock.on('disconnect', process.exit);
console.log('pub bound');
var perTick = program.perTick || 1000;
@@ -22,4 +24,4 @@ function more() {
process.nextTick(more);
}
-more();
+more();
View
@@ -6,6 +6,7 @@ var ss = require('..')
program
.option('-T, --type <name>', 'socket type [sub]', 'sub')
.option('-s, --size <n>', 'message size in bytes [1024]', parseInt)
+ .option('-d, --duration <n>', 'duration of test [5000]', parseInt)
.parse(process.argv)
var sock = ss.socket(program.type);
@@ -49,7 +50,7 @@ function median(arr) {
return arr[arr.length / 2 | 0];
}
-process.on('SIGINT', function(){
+function done(){
var ms = Date.now() - start;
var avg = n / (ms / 1000);
console.log('\n');
@@ -60,4 +61,7 @@ process.on('SIGINT', function(){
console.log(' through: %d mb/s', ((avg * bytes) / 1024 / 1024).toFixed(2));
console.log();
process.exit();
-});
+}
+
+process.on('SIGINT', done);
+setTimeout(done, program.duration);

0 comments on commit 6669081

Please sign in to comment.