summaryrefslogtreecommitdiff
path: root/py/demo/Ice/throughput
diff options
context:
space:
mode:
Diffstat (limited to 'py/demo/Ice/throughput')
-rw-r--r--py/demo/Ice/throughput/Client.py302
-rw-r--r--py/demo/Ice/throughput/Server.py56
2 files changed, 179 insertions, 179 deletions
diff --git a/py/demo/Ice/throughput/Client.py b/py/demo/Ice/throughput/Client.py
index 8f198ceca84..fc5ff5de065 100644
--- a/py/demo/Ice/throughput/Client.py
+++ b/py/demo/Ice/throughput/Client.py
@@ -37,160 +37,160 @@ x: exit
class Client(Ice.Application):
def run(self, args):
- throughput = Demo.ThroughputPrx.checkedCast(self.communicator().propertyToProxy('Throughput.Throughput'))
- if not throughput:
- print args[0] + ": invalid proxy"
- return False
- throughputOneway = Demo.ThroughputPrx.uncheckedCast(throughput.ice_oneway())
-
- bytes = []
- bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize)
- bytes = ['\x00' for x in bytes]
- byteSeq = ''.join(bytes)
-
- stringSeq = []
- stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize)
- stringSeq = ["hello" for x in stringSeq]
-
- structSeq = []
- structSeq[0:Demo.StringDoubleSeqSize] = range(0, Demo.StringDoubleSeqSize)
- for i in range(0, Demo.StringDoubleSeqSize):
- structSeq[i] = Demo.StringDouble()
- structSeq[i].s = "hello"
- structSeq[i].d = 3.14
-
- fixedSeq = []
- fixedSeq[0:Demo.FixedSeqSize] = range(0, Demo.FixedSeqSize)
- for i in range(0, Demo.FixedSeqSize):
- fixedSeq[i] = Demo.Fixed()
- fixedSeq[i].i = 0
- fixedSeq[i].j = 0
- fixedSeq[i].d = 0.0
-
- menu()
-
- throughput.endWarmup() # Initial ping to setup the connection.
-
- currentType = '1'
- seqSize = Demo.ByteSeqSize
-
- c = None
- while c != 'x':
- try:
- c = raw_input("==> ")
-
- repetitions = 100
-
- if c == '1' or c == '2' or c == '3' or c == '4':
- currentType = c
- if c == '1':
- print "using byte sequences"
- seqSize = Demo.ByteSeqSize
- elif c == '2':
- print "using string sequences"
- seqSize = Demo.StringSeqSize
- elif c == '3':
- print "using variable-length struct sequences"
- seqSize = Demo.StringDoubleSeqSize
- elif c == '4':
- print "using fixed-length struct sequences"
- seqSize = Demo.FixedSeqSize
- elif c == 't' or c == 'o' or c == 'r' or c == 'e':
- if c == 't' or c == 'o':
- print "sending",
- elif c == 'r':
- print "receiving",
- elif c == 'e':
- print "sending and receiving",
-
- print repetitions,
- if currentType == '1':
- print "byte",
- elif currentType == '2':
- print "string",
- elif currentType == '3':
- print "variable-length struct",
- elif currentType == '4':
- print "fixed-length struct",
-
- if c == 'o':
- print "sequences of size %d as oneway..." % seqSize
- else:
- print "sequences of size %d..." % seqSize
-
- tsec = time.time()
-
- for i in range(0, repetitions):
- if currentType == '1':
- if c == 't':
- throughput.sendByteSeq(byteSeq)
- elif c == 'o':
- throughputOneway.sendByteSeq(byteSeq)
- elif c == 'r':
- throughput.recvByteSeq()
- elif c == 'e':
- throughput.echoByteSeq(byteSeq)
- elif currentType == '2':
- if c == 't':
- throughput.sendStringSeq(stringSeq)
- elif c == 'o':
- throughputOneway.sendStringSeq(stringSeq)
- elif c == 'r':
- throughput.recvStringSeq()
- elif c == 'e':
- throughput.echoStringSeq(stringSeq)
- elif currentType == '3':
- if c == 't':
- throughput.sendStructSeq(structSeq)
- elif c == 'o':
- throughputOneway.sendStructSeq(structSeq)
- elif c == 'r':
- throughput.recvStructSeq()
- elif c == 'e':
- throughput.echoStructSeq(structSeq)
- elif currentType == '4':
- if c == 't':
- throughput.sendFixedSeq(fixedSeq)
- elif c == 'o':
- throughputOneway.sendFixedSeq(fixedSeq)
- elif c == 'r':
- throughput.recvFixedSeq()
- elif c == 'e':
- throughput.echoFixedSeq(fixedSeq)
-
- tsec = time.time() - tsec
- tmsec = tsec * 1000.0
- print "time for %d sequences: %.3fms" % (repetitions, tmsec)
- print "time per sequence: %.3fms" % (tmsec / repetitions)
- wireSize = 0
- if currentType == '1':
- wireSize = 1
- elif currentType == '2':
- wireSize = len(stringSeq[0])
- elif currentType == '3':
- wireSize = len(structSeq[0].s)
- wireSize += 8
- elif currentType == '4':
- wireSize = 16
- mbit = repetitions * seqSize * wireSize * 8.0 / tsec / 1000000.0
- if c == 'e':
- mbit = mbit * 2
- print "throughput: %.3fMbps" % mbit
- elif c == 's':
- throughput.shutdown()
- elif c == 'x':
- pass # Nothing to do
- elif c == '?':
- menu()
- else:
- print "unknown command `" + c + "'"
- menu()
- except EOFError:
- break
+ throughput = Demo.ThroughputPrx.checkedCast(self.communicator().propertyToProxy('Throughput.Throughput'))
+ if not throughput:
+ print args[0] + ": invalid proxy"
+ return False
+ throughputOneway = Demo.ThroughputPrx.uncheckedCast(throughput.ice_oneway())
+
+ bytes = []
+ bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize)
+ bytes = ['\x00' for x in bytes]
+ byteSeq = ''.join(bytes)
+
+ stringSeq = []
+ stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize)
+ stringSeq = ["hello" for x in stringSeq]
+
+ structSeq = []
+ structSeq[0:Demo.StringDoubleSeqSize] = range(0, Demo.StringDoubleSeqSize)
+ for i in range(0, Demo.StringDoubleSeqSize):
+ structSeq[i] = Demo.StringDouble()
+ structSeq[i].s = "hello"
+ structSeq[i].d = 3.14
+
+ fixedSeq = []
+ fixedSeq[0:Demo.FixedSeqSize] = range(0, Demo.FixedSeqSize)
+ for i in range(0, Demo.FixedSeqSize):
+ fixedSeq[i] = Demo.Fixed()
+ fixedSeq[i].i = 0
+ fixedSeq[i].j = 0
+ fixedSeq[i].d = 0.0
+
+ menu()
+
+ throughput.endWarmup() # Initial ping to setup the connection.
+
+ currentType = '1'
+ seqSize = Demo.ByteSeqSize
+
+ c = None
+ while c != 'x':
+ try:
+ c = raw_input("==> ")
+
+ repetitions = 100
+
+ if c == '1' or c == '2' or c == '3' or c == '4':
+ currentType = c
+ if c == '1':
+ print "using byte sequences"
+ seqSize = Demo.ByteSeqSize
+ elif c == '2':
+ print "using string sequences"
+ seqSize = Demo.StringSeqSize
+ elif c == '3':
+ print "using variable-length struct sequences"
+ seqSize = Demo.StringDoubleSeqSize
+ elif c == '4':
+ print "using fixed-length struct sequences"
+ seqSize = Demo.FixedSeqSize
+ elif c == 't' or c == 'o' or c == 'r' or c == 'e':
+ if c == 't' or c == 'o':
+ print "sending",
+ elif c == 'r':
+ print "receiving",
+ elif c == 'e':
+ print "sending and receiving",
+
+ print repetitions,
+ if currentType == '1':
+ print "byte",
+ elif currentType == '2':
+ print "string",
+ elif currentType == '3':
+ print "variable-length struct",
+ elif currentType == '4':
+ print "fixed-length struct",
+
+ if c == 'o':
+ print "sequences of size %d as oneway..." % seqSize
+ else:
+ print "sequences of size %d..." % seqSize
+
+ tsec = time.time()
+
+ for i in range(0, repetitions):
+ if currentType == '1':
+ if c == 't':
+ throughput.sendByteSeq(byteSeq)
+ elif c == 'o':
+ throughputOneway.sendByteSeq(byteSeq)
+ elif c == 'r':
+ throughput.recvByteSeq()
+ elif c == 'e':
+ throughput.echoByteSeq(byteSeq)
+ elif currentType == '2':
+ if c == 't':
+ throughput.sendStringSeq(stringSeq)
+ elif c == 'o':
+ throughputOneway.sendStringSeq(stringSeq)
+ elif c == 'r':
+ throughput.recvStringSeq()
+ elif c == 'e':
+ throughput.echoStringSeq(stringSeq)
+ elif currentType == '3':
+ if c == 't':
+ throughput.sendStructSeq(structSeq)
+ elif c == 'o':
+ throughputOneway.sendStructSeq(structSeq)
+ elif c == 'r':
+ throughput.recvStructSeq()
+ elif c == 'e':
+ throughput.echoStructSeq(structSeq)
+ elif currentType == '4':
+ if c == 't':
+ throughput.sendFixedSeq(fixedSeq)
+ elif c == 'o':
+ throughputOneway.sendFixedSeq(fixedSeq)
+ elif c == 'r':
+ throughput.recvFixedSeq()
+ elif c == 'e':
+ throughput.echoFixedSeq(fixedSeq)
+
+ tsec = time.time() - tsec
+ tmsec = tsec * 1000.0
+ print "time for %d sequences: %.3fms" % (repetitions, tmsec)
+ print "time per sequence: %.3fms" % (tmsec / repetitions)
+ wireSize = 0
+ if currentType == '1':
+ wireSize = 1
+ elif currentType == '2':
+ wireSize = len(stringSeq[0])
+ elif currentType == '3':
+ wireSize = len(structSeq[0].s)
+ wireSize += 8
+ elif currentType == '4':
+ wireSize = 16
+ mbit = repetitions * seqSize * wireSize * 8.0 / tsec / 1000000.0
+ if c == 'e':
+ mbit = mbit * 2
+ print "throughput: %.3fMbps" % mbit
+ elif c == 's':
+ throughput.shutdown()
+ elif c == 'x':
+ pass # Nothing to do
+ elif c == '?':
+ menu()
+ else:
+ print "unknown command `" + c + "'"
+ menu()
+ except EOFError:
+ break
except KeyboardInterrupt:
break
- return True
+ return True
app = Client()
sys.exit(app.main(sys.argv, "config.client"))
diff --git a/py/demo/Ice/throughput/Server.py b/py/demo/Ice/throughput/Server.py
index b7009b0a9c2..9f03be11d3b 100644
--- a/py/demo/Ice/throughput/Server.py
+++ b/py/demo/Ice/throughput/Server.py
@@ -16,11 +16,11 @@ import Demo
class ThroughputI(Demo.Throughput):
def __init__(self):
warmup = True
-
- bytes = []
- bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize)
- bytes = ['\x00' for x in bytes]
- self.byteSeq = ''.join(bytes)
+
+ bytes = []
+ bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize)
+ bytes = ['\x00' for x in bytes]
+ self.byteSeq = ''.join(bytes)
self.stringSeq = []
self.stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize)
@@ -28,29 +28,29 @@ class ThroughputI(Demo.Throughput):
self.structSeq = []
self.structSeq[0:Demo.StringDoubleSeqSize] = range(0, Demo.StringDoubleSeqSize)
- for i in range(0, Demo.StringDoubleSeqSize):
- self.structSeq[i] = Demo.StringDouble()
- self.structSeq[i].s = "hello"
- self.structSeq[i].d = 3.14
+ for i in range(0, Demo.StringDoubleSeqSize):
+ self.structSeq[i] = Demo.StringDouble()
+ self.structSeq[i].s = "hello"
+ self.structSeq[i].d = 3.14
self.fixedSeq = []
self.fixedSeq[0:Demo.FixedSeqSize] = range(0, Demo.FixedSeqSize)
- for i in range(0, Demo.FixedSeqSize):
- self.fixedSeq[i] = Demo.Fixed()
- self.fixedSeq[i].i = 0
- self.fixedSeq[i].j = 0
- self.fixedSeq[i].d = 0.0
+ for i in range(0, Demo.FixedSeqSize):
+ self.fixedSeq[i] = Demo.Fixed()
+ self.fixedSeq[i].i = 0
+ self.fixedSeq[i].j = 0
+ self.fixedSeq[i].d = 0.0
def endWarmup(self, current=None):
self.warmup = False
-
+
def sendByteSeq(self, seq, current=None):
pass
def recvByteSeq(self, current=None):
if self.warmup:
- return []
- else:
+ return []
+ else:
return self.byteSeq
def echoByteSeq(self, seq, current=None):
@@ -61,8 +61,8 @@ class ThroughputI(Demo.Throughput):
def recvStringSeq(self, current=None):
if self.warmup:
- return []
- else:
+ return []
+ else:
return self.stringSeq
def echoStringSeq(self, seq, current=None):
@@ -73,8 +73,8 @@ class ThroughputI(Demo.Throughput):
def recvStructSeq(self, current=None):
if self.warmup:
- return []
- else:
+ return []
+ else:
return self.structSeq
def echoStructSeq(self, seq, current=None):
@@ -85,8 +85,8 @@ class ThroughputI(Demo.Throughput):
def recvFixedSeq(self, current=None):
if self.warmup:
- return []
- else:
+ return []
+ else:
return self.fixedSeq
def echoFixedSeq(self, seq, current=None):
@@ -97,11 +97,11 @@ class ThroughputI(Demo.Throughput):
class Server(Ice.Application):
def run(self, args):
- adapter = self.communicator().createObjectAdapter("Throughput")
- adapter.add(ThroughputI(), self.communicator().stringToIdentity("throughput"))
- adapter.activate()
- self.communicator().waitForShutdown()
- return True
+ adapter = self.communicator().createObjectAdapter("Throughput")
+ adapter.add(ThroughputI(), self.communicator().stringToIdentity("throughput"))
+ adapter.activate()
+ self.communicator().waitForShutdown()
+ return True
app = Server()
sys.exit(app.main(sys.argv, "config.server"))