Permalink
Browse files

passed multi-execution test

  • Loading branch information...
1 parent 3b9a082 commit b86f0584a50ca269f0e65ae639485e199d66f4b8 @brianc committed Dec 21, 2010
Showing with 17 additions and 3 deletions.
  1. +14 −3 lib/index.js
  2. +3 −0 test/initial-tests.js
View
17 lib/index.js
@@ -1,9 +1,20 @@
module.exports = {
bench: function(config) {
return function(callback) {
- config.actions.forEach(function(action) {
- action.run.call(action, callback)
- })
+ var action = config.actions[0];
+ var i = 0
+ var doAction = function(action) {
+ console.log("i: %d", i);
+ //no more repeats to execute
+ if(config.repeat > i++) {
+ action.run(function() {
+ doAction(action)
+ })
+ } else {
+ callback();
+ }
+ }
+ doAction(action)
}
}
}
View
3 test/initial-tests.js
@@ -4,6 +4,7 @@ var bencher = require(__dirname + '/../lib');
test('simplest thing ever',function() {
var ran = 0;
var benchmark = bencher.bench({
+ repeat: 1,
actions:[{
name: 'first',
run: function(next) {
@@ -22,9 +23,11 @@ test('simplest thing ever',function() {
test('multiple itterations', function() {
var ran = 0;
var benchmark = bencher.bench({
+ repeat: 3,
actions:[{
name: 'multiple',
run: function(next) {
+ console.log("ran: %d", ran);
ran++;
next();
}

0 comments on commit b86f058

Please sign in to comment.