diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2005-03-01 17:15:21 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2005-03-01 17:15:21 +0000 |
commit | b2de273e12d4496644c5865bd0c87828b2a79973 (patch) | |
tree | 84787d7503b8db09a997a36965d3b29fc647fe3b /java/demo | |
parent | fix (diff) | |
download | ice-b2de273e12d4496644c5865bd0c87828b2a79973.tar.bz2 ice-b2de273e12d4496644c5865bd0c87828b2a79973.tar.xz ice-b2de273e12d4496644c5865bd0c87828b2a79973.zip |
Ported new throughput demo
Diffstat (limited to 'java/demo')
-rw-r--r-- | java/demo/Ice/throughput/Client.java | 224 | ||||
-rw-r--r-- | java/demo/Ice/throughput/Throughput.ice | 24 | ||||
-rw-r--r-- | java/demo/Ice/throughput/ThroughputI.java | 68 |
3 files changed, 282 insertions, 34 deletions
diff --git a/java/demo/Ice/throughput/Client.java b/java/demo/Ice/throughput/Client.java index 1cf7f53004e..a9121acd7fe 100644 --- a/java/demo/Ice/throughput/Client.java +++ b/java/demo/Ice/throughput/Client.java @@ -15,13 +15,23 @@ public class Client menu() { System.out.println( - "usage:\n" + - "s: send byte sequence\n" + - "o: send byte sequence as oneway\n" + - "r: receive byte sequence\n" + - "e: echo (send and receive) byte sequence\n" + - "x: exit\n" + - "?: help\n"); + "usage:\n" + + "\n" + + "toggle type of data to send:\n" + + "1: sequence of bytes (default)\n" + + "2: sequence of strings (\"hello\")\n" + + "3: sequence of structs with a string (\"hello\") and a double\n" + + "\n" + + "select test to run:\n" + + "t: Send sequence as twoway\n" + + "o: Send sequence as oneway\n" + + "r: Receive sequence\n" + + "e: Echo (send and receive) sequence\n" + + "\n" + + "other commands:\n" + + "s: shutdown server\n" + + "x: exit\n" + + "?: help\n"); } private static int @@ -45,12 +55,29 @@ public class Client } ThroughputPrx throughputOneway = ThroughputPrxHelper.uncheckedCast(throughput.ice_oneway()); - byte[] seq = new byte[seqSize.value]; + byte[] byteSeq = new byte[ByteSeqSize.value]; + + String[] stringSeq = new String[StringSeqSize.value]; + for(int i = 0; i < StringSeqSize.value; ++i) + { + stringSeq[i] = "hello"; + } + + StringDouble[] structSeq = new StringDouble[StringDoubleSeqSize.value]; + for(int i = 0; i < StringDoubleSeqSize.value; ++i) + { + structSeq[i] = new StringDouble(); + structSeq[i].s = "hello"; + structSeq[i].d = 3.14; + } menu(); java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); + char currentType = '1'; + int seqSize = ByteSeqSize.value; + String line = null; do { @@ -70,13 +97,41 @@ public class Client long tmsec = System.currentTimeMillis(); final int repetitions = 100; - if(line.equals("s") || line.equals("o") || line.equals("r") || line.equals("e")) + if(line.equals("1") || line.equals("2") || line.equals("3")) + { + currentType = line.charAt(0); + + switch(currentType) + { + case '1': + { + System.out.println("using byte sequences"); + seqSize = ByteSeqSize.value; + break; + } + + case '2': + { + System.out.println("using string sequences"); + seqSize = StringSeqSize.value; + break; + } + + case '3': + { + System.out.println("using struct sequences"); + seqSize = StringDoubleSeqSize.value; + break; + } + } + } + else if(line.equals("t") || line.equals("o") || line.equals("r") || line.equals("e")) { char c = line.charAt(0); switch(c) { - case 's': + case 't': case 'o': { System.out.print("sending"); @@ -96,7 +151,29 @@ public class Client } } - System.out.print(" " + repetitions + " sequences of size " + seqSize.value); + System.out.print(" " + repetitions); + switch(currentType) + { + case '1': + { + System.out.print(" byte"); + break; + } + + case '2': + { + System.out.print(" string"); + break; + } + + case '3': + { + System.out.print(" struct"); + break; + } + } + + System.out.print(" sequences of size " + seqSize); if(c == 'o') { @@ -107,29 +184,98 @@ public class Client for(int i = 0; i < repetitions; ++i) { - switch(c) + switch(currentType) { - case 's': + case '1': { - throughput.sendByteSeq(seq); - break; - } + switch(c) + { + case 't': + { + throughput.sendByteSeq(byteSeq); + break; + } - case 'o': - { - throughputOneway.sendByteSeq(seq); + case 'o': + { + throughputOneway.sendByteSeq(byteSeq); + break; + } + + case 'r': + { + throughput.recvByteSeq(); + break; + } + + case 'e': + { + throughput.echoByteSeq(byteSeq); + break; + } + } break; } - - case 'r': + + case '2': { - throughput.recvByteSeq(); + switch(c) + { + case 't': + { + throughput.sendStringSeq(stringSeq); + break; + } + + case 'o': + { + throughputOneway.sendStringSeq(stringSeq); + break; + } + + case 'r': + { + throughput.recvStringSeq(); + break; + } + + case 'e': + { + throughput.echoStringSeq(stringSeq); + break; + } + } break; } - - case 'e': + + case '3': { - throughput.echoByteSeq(seq); + switch(c) + { + case 't': + { + throughput.sendStructSeq(structSeq); + break; + } + + case 'o': + { + throughputOneway.sendStructSeq(structSeq); + break; + } + + case 'r': + { + throughput.recvStructSeq(); + break; + } + + case 'e': + { + throughput.echoStructSeq(structSeq); + break; + } + } break; } } @@ -138,13 +284,39 @@ public class Client double dmsec = System.currentTimeMillis() - tmsec; System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms"); System.out.println("time per sequence: " + dmsec / repetitions + "ms"); - double mbit = repetitions * seqSize.value * 8.0 / dmsec / 1000.0; + int wireSize = 0; + switch(currentType) + { + case '1': + { + wireSize = 1; + break; + } + + case '2': + { + wireSize = stringSeq[0].length(); + break; + } + + case '3': + { + wireSize = structSeq[0].s.length(); + wireSize += 8; // Size of double on the wire. + break; + } + } + double mbit = repetitions * seqSize * wireSize * 8.0 / dmsec / 1000.0; if(c == 'e') { mbit *= 2; } System.out.println("throughput: " + mbit + " MBit/s"); } + else if(line.equals("s")) + { + throughput.shutdown(); + } else if(line.equals("x")) { // Nothing to do diff --git a/java/demo/Ice/throughput/Throughput.ice b/java/demo/Ice/throughput/Throughput.ice index 42a614186ae..47d3f8c6743 100644 --- a/java/demo/Ice/throughput/Throughput.ice +++ b/java/demo/Ice/throughput/Throughput.ice @@ -13,15 +13,35 @@ module Demo { -const int seqSize = 500000; - sequence<byte> ByteSeq; +const int ByteSeqSize = 500000; + +sequence<string> StringSeq; +const int StringSeqSize = 50000; + +struct StringDouble +{ + string s; + double d; +}; +sequence<StringDouble> StringDoubleSeq; +const int StringDoubleSeqSize = 50000; interface Throughput { void sendByteSeq(ByteSeq seq); ByteSeq recvByteSeq(); ByteSeq echoByteSeq(ByteSeq seq); + + void sendStringSeq(StringSeq seq); + StringSeq recvStringSeq(); + StringSeq echoStringSeq(StringSeq seq); + + void sendStructSeq(StringDoubleSeq seq); + StringDoubleSeq recvStructSeq(); + StringDoubleSeq echoStructSeq(StringDoubleSeq seq); + + idempotent void shutdown(); }; }; diff --git a/java/demo/Ice/throughput/ThroughputI.java b/java/demo/Ice/throughput/ThroughputI.java index 826049af283..d31b91fdac1 100644 --- a/java/demo/Ice/throughput/ThroughputI.java +++ b/java/demo/Ice/throughput/ThroughputI.java @@ -14,7 +14,32 @@ public final class ThroughputI extends _ThroughputDisp public ThroughputI() { - _seq = new byte[seqSize.value]; + _byteSeq = new byte[ByteSeqSize.value]; + + _stringSeq = new String[StringSeqSize.value]; + for(int i = 0; i < StringSeqSize.value; ++i) + { + _stringSeq[i] = "hello"; + } + + _structSeq = new StringDouble[StringDoubleSeqSize.value]; + for(int i = 0; i < StringDoubleSeqSize.value; ++i) + { + _structSeq[i] = new StringDouble(); + _structSeq[i].s = "hello"; + _structSeq[i].d = 3.14; + } + } + + public void + sendByteSeq(byte[] seq, Ice.Current current) + { + } + + public byte[] + recvByteSeq(Ice.Current current) + { + return _byteSeq; } public byte[] @@ -23,16 +48,47 @@ public final class ThroughputI extends _ThroughputDisp return seq; } - public byte[] - recvByteSeq(Ice.Current current) + public void + sendStringSeq(String[] seq, Ice.Current current) + { + } + + public String[] + recvStringSeq(Ice.Current current) { - return _seq; + return _stringSeq; + } + + public String[] + echoStringSeq(String[] seq, Ice.Current current) + { + return seq; } public void - sendByteSeq(byte[] seq, Ice.Current current) + sendStructSeq(StringDouble[] seq, Ice.Current current) + { + } + + public StringDouble[] + recvStructSeq(Ice.Current current) + { + return _structSeq; + } + + public StringDouble[] + echoStructSeq(StringDouble[] seq, Ice.Current current) + { + return seq; + } + + public void + shutdown(Ice.Current current) { + current.adapter.getCommunicator().shutdown(); } - private byte[] _seq; + private byte[] _byteSeq; + private String[] _stringSeq; + private StringDouble[] _structSeq; } |