Skip to content
Browse files

Workaround to avoid ENOBUFS error

  • Loading branch information...
1 parent 9e22fdb commit 7a39a2a1f57a2bcb7b79f6ec0487326d734f3bae @penartur committed May 4, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/benchmark.js
View
12 lib/benchmark.js
@@ -149,24 +149,32 @@ BenchmarkContext.prototype.runPage = function (engineName, pageName, over) {
(function (err, total) {
if (err) {
console.log(err);
+ } else {
+ this.responseTimes[pageName][engineName].push(total);
}
- this.responseTimes[pageName][engineName].push(total);
over();
}).bind(this)
);
}
BenchmarkContext.prototype.runEngine = function (engineName, over) {
+ var tasks = 0;
+ console.log("runEngine");
var queue = new WorkingQueue(this.simultaneousRequests);
queue.hold();
for (var i = 0; i < this.benchmark.options.iterations * this.simultaneousRequests; i++) {
for (var pageName in this.benchmark.pages) {
for (var j = 0; j < this.benchmark.pages[pageName].weight; j++) {
queue.perform(this.runPage.bind(this), engineName, pageName);
+ tasks++;
}
}
}
- queue.whenDone(over);
+ queue.whenDone(function () {
+ var timeout = tasks * 10;
+ console.log("done, waiting " + timeout + "ms");
+ setTimeout(over, tasks * 10); //to workaround ENOBUFS
+ });
queue.go();
}

0 comments on commit 7a39a2a

Please sign in to comment.
Something went wrong with that request. Please try again.