Permalink
Browse files

websocket latency test fix

  • Loading branch information...
1 parent a9e145a commit eedf2c0e9bae5bc95d2e8ebf6a0d8fcee4ad9838 @tjanczuk tjanczuk committed Oct 23, 2012
Showing with 14 additions and 4 deletions.
  1. +14 −4 test/stress/132_websocket_latency/index.html
@@ -29,9 +29,10 @@ <h1>132_websocket_latency</h1>
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
var scenarioAddress = {
iisnode: protocol + window.location.host + window.location.pathname + '/server.js',
- node: protocol + 'localhost:8888'
+ node: protocol + window.location.host + ':8888/'
};
var measurements = 30;
+ var maxErrors = 5;
var progress = 0;
function measureOne(address, callback) {
@@ -54,6 +55,10 @@ <h1>132_websocket_latency</h1>
}
socket.onclose = function () {
+ if (!error && (isNaN(open) || isNaN(receive))) {
+ error = new Error('Inconclusive measurement');
+ }
+
callback(error, open ? open - start : undefined, receive ? receive - start: undefined);
};
}
@@ -70,15 +75,20 @@ <h1>132_websocket_latency</h1>
var count = 0;
var openSum = 0;
var echoSum = 0;
+ var errorCount = 0;
function runOnce() {
- measureOne(scenarioAddress[scenario], function (error, open, echo) {
+ measureOne(scenarioAddress[scenario], function (error, open, echo) {
if (error) {
- return callback(error);
+ if (++errorCount > maxErrors) {
+ return callback(error);
+ }
+ else {
+ return runOnce();
+ }
}
setProgress(++progress);
-
openSum += open;
echoSum += echo;
count++;

0 comments on commit eedf2c0

Please sign in to comment.