summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-10-15 12:20:19 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-10-15 12:20:19 -0230
commitf013d74ce935b5a4acde0ef12907992f0236cace (patch)
treefd0fd8c09f810ec5d6258b9ebb49e28fdcd4aa03
parentFixed ICE-5454: close acceptor on adapter deactivation (diff)
downloadice-f013d74ce935b5a4acde0ef12907992f0236cace.tar.bz2
ice-f013d74ce935b5a4acde0ef12907992f0236cace.tar.xz
ice-f013d74ce935b5a4acde0ef12907992f0236cace.zip
ICE-5732 missing tracing in throughput demo
-rw-r--r--js/demo/Ice/throughput/Client.js40
-rw-r--r--js/demo/Ice/throughput/browser/Client.js32
-rw-r--r--js/src/Ice/ConnectionI.js21
-rw-r--r--js/src/Ice/TcpTransceiver.js6
-rw-r--r--js/src/Ice/browser/WSTransceiver.js12
5 files changed, 66 insertions, 45 deletions
diff --git a/js/demo/Ice/throughput/Client.js b/js/demo/Ice/throughput/Client.js
index 910b8c30a3c..64f17a91dd0 100644
--- a/js/demo/Ice/throughput/Client.js
+++ b/js/demo/Ice/throughput/Client.js
@@ -41,7 +41,7 @@ function menu()
function loop(fn, repetitions)
{
var i = 0;
- var next = function()
+ var next = function()
{
if(i++ < repetitions)
{
@@ -89,18 +89,18 @@ Ice.Promise.try(
{
var currentType = "1";
var repetitions = 100;
-
+
var seqSize = Demo.ByteSeqSize;
var seq = byteSeq;
var wireSize = 1;
-
+
//
// Initialize the communicator and create a proxy
// to the throughput object.
//
communicator = Ice.initialize(process.argv);
var proxy = communicator.stringToProxy("throughput:default -p 10000");
-
+
//
// Down-cast the proxy to the Demo.Throughput interface.
//
@@ -111,7 +111,7 @@ Ice.Promise.try(
menu();
process.stdout.write("==> ");
var keyLoop = new Ice.Promise();
-
+
function processKey(key)
{
if(key == "x")
@@ -119,10 +119,10 @@ Ice.Promise.try(
keyLoop.succeed();
return;
}
-
+
var proxy;
var operation;
-
+
if(key == "1" || key == "2" || key == "3" || key == "4")
{
currentType = key;
@@ -200,7 +200,7 @@ Ice.Promise.try(
process.stdout.write("sending");
break;
}
-
+
case "r":
{
proxy = twoway;
@@ -223,7 +223,7 @@ Ice.Promise.try(
process.stdout.write("receiving");
break;
}
-
+
case "e":
{
proxy = twoway;
@@ -247,7 +247,7 @@ Ice.Promise.try(
break;
}
}
-
+
process.stdout.write(" " + repetitions);
switch(currentType)
{
@@ -273,7 +273,7 @@ Ice.Promise.try(
break;
}
}
-
+
process.stdout.write(" sequences of size " + seqSize);
if(key == "o")
@@ -281,11 +281,11 @@ Ice.Promise.try(
process.stdout.write(" as oneway");
}
console.log("...");
-
+
var start = new Date().getTime();
var args = key != "r" ? [seq] : [];
return loop(
- function()
+ function()
{
return operation.apply(proxy, args);
},
@@ -299,7 +299,7 @@ Ice.Promise.try(
var total = new Date().getTime() - start;
console.log("time for " + repetitions + " sequences: " + total + " ms");
console.log("time per sequence: " + total / repetitions + " ms");
-
+
var mbit = repetitions * seqSize * wireSize * 8.0 / total / 1000.0;
if(key == "e")
{
@@ -326,7 +326,7 @@ Ice.Promise.try(
menu();
}
}
-
+
//
// Process keys sequentially. We chain the promise objects
// returned by processKey(). Once we have process all the
@@ -334,7 +334,7 @@ Ice.Promise.try(
//
process.stdin.resume();
var promise = new Ice.Promise().succeed();
- process.stdin.on("data",
+ process.stdin.on("data",
function(buffer)
{
process.stdin.pause();
@@ -343,9 +343,9 @@ Ice.Promise.try(
data.forEach(function(key)
{
promise = promise.then(
- function(r)
- {
- return processKey(key);
+ function(r)
+ {
+ return processKey(key);
}
).exception(
function(ex)
@@ -354,7 +354,7 @@ Ice.Promise.try(
});
});
// Once we're done, print the prompt
- promise.then(function()
+ promise.then(function()
{
if(!keyLoop.completed())
{
diff --git a/js/demo/Ice/throughput/browser/Client.js b/js/demo/Ice/throughput/browser/Client.js
index 133481e3ea4..1978a93045c 100644
--- a/js/demo/Ice/throughput/browser/Client.js
+++ b/js/demo/Ice/throughput/browser/Client.js
@@ -14,7 +14,7 @@ var ThroughputPrx = Demo.ThroughputPrx;
//
// Initialize sequences.
//
-var byteSeq = new ArrayBuffer();
+var byteSeq = new Uint8Array(Demo.ByteSeqSize);
for(var i = 0; i < Demo.ByteSeqSize; ++i)
{
byteSeq[i] = 0;
@@ -55,11 +55,11 @@ function run()
//
var hostname = document.location.hostname || "127.0.0.1";
var secure = document.location.protocol.indexOf("https") != -1;
- var ref = secure ?
+ var ref = secure ?
"throughput:wss -h " + hostname + " -p 9090 -r /demowss" :
"throughput:ws -h " + hostname + " -p 8080 -r /demows";
var proxy = communicator.stringToProxy(ref);
-
+
//
// Down-cast the proxy to the Demo.Throughput interface.
//
@@ -67,14 +67,14 @@ function run()
function(twoway)
{
oneway = twoway.ice_oneway();
-
+
var seq;
var seqSize
var wireSize;
var proxy;
var operation;
var repetitions = 100;
-
+
var data = $("#data").val();
//
// Get the sequence data
@@ -114,7 +114,7 @@ function run()
//
wireSize = 16;
}
-
+
//
// Get the proxy and operation
//
@@ -182,7 +182,7 @@ function run()
}
write("sending and receiving");
}
-
+
write(" " + repetitions);
if(data == "byte-seq")
{
@@ -206,10 +206,10 @@ function run()
write(" as oneway");
}
writeLine("...");
-
+
//
// Invoke the test operation in a loop with the required
- // arguments.
+ // arguments.
//
// We chain the promises. A test operation is called only
// once the promise for the previous operation is
@@ -218,7 +218,7 @@ function run()
var start = new Date().getTime();
var args = test != "receive" ? [seq] : [];
return loop(
- function()
+ function()
{
return operation.apply(proxy, args);
},
@@ -232,7 +232,7 @@ function run()
var total = new Date().getTime() - start;
writeLine("time for " + repetitions + " sequences: " + total + " ms");
writeLine("time per sequence: " + total / repetitions + " ms");
-
+
var mbit = repetitions * seqSize * wireSize * 8.0 / total / 1000.0;
if(test == "echo")
{
@@ -277,11 +277,11 @@ $("#run").click(
//
// Asynchronous loop: each call to the given function returns a
// promise that when fulfilled runs the next iteration.
-//
+//
function loop(fn, repetitions)
{
var i = 0;
- var next = function()
+ var next = function()
{
if(i++ < repetitions)
{
@@ -308,9 +308,9 @@ function writeLine(msg)
//
// Handle the client state.
//
-var State = {
- Idle:0,
- Running: 1
+var State = {
+ Idle:0,
+ Running: 1
};
var state;
diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js
index e1dbe937e09..28b2e60352a 100644
--- a/js/src/Ice/ConnectionI.js
+++ b/js/src/Ice/ConnectionI.js
@@ -163,7 +163,26 @@ var ConnectionI = Class({
this._transceiver.setCallbacks(
function() { self.message(SocketOperation.Write); }, // connected callback
function() { self.message(SocketOperation.Read); }, // read callback
- function() { self.message(SocketOperation.Write); } // write callback
+ function(bytesSent, bytesTotal) {
+ self.message(SocketOperation.Write);
+ if(self._instance.traceLevels().network >= 3 && bytesSent > 0)
+ {
+ var s = [];
+ s.push("sent ");
+ s.push(bytesSent);
+ if(!self._endpoint.datagram())
+ {
+ s.push(" of ");
+ s.push(bytesTotal);
+ }
+ s.push(" bytes via ");
+ s.push(self._endpoint.protocol());
+ s.push("\n");
+ s.push(this.toString());
+ self._instance.initializationData().logger.trace(self._instance.traceLevels().networkCat,
+ s.join(""));
+ }
+ } // write callback
);
this.initialize();
}
diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js
index 67449cc4525..63d150d00bb 100644
--- a/js/src/Ice/TcpTransceiver.js
+++ b/js/src/Ice/TcpTransceiver.js
@@ -154,7 +154,8 @@ var TcpTransceiver = Ice.Class({
throw this._exception;
}
- var packetSize = byteBuffer.remaining;
+ var bytesTotal = byteBuffer.remaining;
+ var packetSize = bytesTotal;
Debug.assert(packetSize > 0);
if(this._maxSendPacketSize > 0 && packetSize > this._maxSendPacketSize)
@@ -174,6 +175,7 @@ var TcpTransceiver = Ice.Class({
return;
}
+ var bytesSent = packetSize;
byteBuffer.position = byteBuffer.position + packetSize;
if(this._maxSendPacketSize > 0 && byteBuffer.remaining > this._maxSendPacketSize)
{
@@ -183,7 +185,7 @@ var TcpTransceiver = Ice.Class({
{
packetSize = byteBuffer.remaining;
}
- self._bytesWrittenCallback();
+ self._bytesWrittenCallback(bytesSent, bytesTotal);
});
if(sync)
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js
index fb74a45797e..eaa7d3cc59d 100644
--- a/js/src/Ice/browser/WSTransceiver.js
+++ b/js/src/Ice/browser/WSTransceiver.js
@@ -50,17 +50,17 @@ var WSTransceiver = Ice.Class({
this._bytesAvailableCallback = bytesAvailableCallback;
var transceiver = this;
- this._bytesWrittenCallback = function()
+ this._bytesWrittenCallback = function(bytesSent, bytesTotal)
{
if(transceiver._fd)
{
if(transceiver._fd.bufferedAmount < 1024 || this._exception)
{
- bytesWrittenCallback();
+ bytesWrittenCallback(bytesSent, bytesTotal);
}
else
{
- setTimeout(transceiver._bytesWrittenCallback, 50);
+ setTimeout(function() { transceiver._bytesWrittenCallback(bytesSent, bytesTotal); }, 50);
}
}
};
@@ -180,9 +180,10 @@ var WSTransceiver = Ice.Class({
return true;
}
+ var transceiver = this;
if(this._fd.bufferedAmount > 1024)
{
- setTimeout(this._bytesWrittenCallback, 50);
+ setTimeout(function() { transceiver._bytesWrittenCallback(0, 0); }, 50);
return false;
}
@@ -201,7 +202,6 @@ var WSTransceiver = Ice.Class({
this._fd.send(slice);
byteBuffer.position = byteBuffer.position + packetSize;
-
if(this._maxSendPacketSize > 0 && byteBuffer.remaining > this._maxSendPacketSize)
{
packetSize = this._maxSendPacketSize;
@@ -213,7 +213,7 @@ var WSTransceiver = Ice.Class({
if(this._fd.bufferedAmount > 0 && packetSize > 0)
{
- setTimeout(this._bytesWrittenCallback, 50);
+ setTimeout(function() { transceiver._bytesWrittenCallback(0, 0); }, 50);
return false;
}
}