diff options
Diffstat (limited to 'java/demo/Ice/throughput/Client.java')
-rw-r--r-- | java/demo/Ice/throughput/Client.java | 680 |
1 files changed, 340 insertions, 340 deletions
diff --git a/java/demo/Ice/throughput/Client.java b/java/demo/Ice/throughput/Client.java index 95139d85bb3..f413bc855b7 100644 --- a/java/demo/Ice/throughput/Client.java +++ b/java/demo/Ice/throughput/Client.java @@ -13,18 +13,18 @@ public class Client extends Ice.Application { class ShutdownHook extends Thread { - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } + public void + run() + { + try + { + communicator().destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } } private static void @@ -54,12 +54,12 @@ public class Client extends Ice.Application public int run(String[] args) { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); + // + // Since this is an interactive demo we want to clear the + // Application installed interrupt callback and install our + // own shutdown hook. + // + setInterruptHook(new ShutdownHook()); Ice.ObjectPrx base = communicator().propertyToProxy("Throughput.Throughput"); ThroughputPrx throughput = ThroughputPrxHelper.checkedCast(base); @@ -68,32 +68,32 @@ public class Client extends Ice.Application System.err.println("invalid proxy"); return 1; } - ThroughputPrx throughputOneway = ThroughputPrxHelper.uncheckedCast(throughput.ice_oneway()); + ThroughputPrx throughputOneway = ThroughputPrxHelper.uncheckedCast(throughput.ice_oneway()); 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; - } - - Fixed[] fixedSeq = new Fixed[FixedSeqSize.value]; - for(int i = 0; i < FixedSeqSize.value; ++i) - { - fixedSeq[i] = new Fixed(); - fixedSeq[i].i = 0; - fixedSeq[i].j = 0; - fixedSeq[i].d = 0; - } + 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; + } + + Fixed[] fixedSeq = new Fixed[FixedSeqSize.value]; + for(int i = 0; i < FixedSeqSize.value; ++i) + { + fixedSeq[i] = new Fixed(); + fixedSeq[i].i = 0; + fixedSeq[i].j = 0; + fixedSeq[i].d = 0; + } // // A method needs to be invoked thousands of times before the JIT compiler @@ -102,49 +102,49 @@ public class Client extends Ice.Application // { byte[] emptyBytes= new byte[1]; - String[] emptyStrings = new String[1]; - StringDouble[] emptyStructs = new StringDouble[1]; - emptyStructs[0] = new StringDouble(); - Fixed[] emptyFixed = new Fixed[1]; - emptyFixed[0] = new Fixed(); + String[] emptyStrings = new String[1]; + StringDouble[] emptyStructs = new StringDouble[1]; + emptyStructs[0] = new StringDouble(); + Fixed[] emptyFixed = new Fixed[1]; + emptyFixed[0] = new Fixed(); final int repetitions = 10000; System.out.print("warming up the JIT compiler..."); System.out.flush(); for(int i = 0; i < repetitions; i++) { - throughput.sendByteSeq(emptyBytes); - throughput.sendStringSeq(emptyStrings); - throughput.sendStructSeq(emptyStructs); - throughput.sendFixedSeq(emptyFixed); - - throughput.recvByteSeq(); - throughput.recvStringSeq(); - throughput.recvStructSeq(); - throughput.recvFixedSeq(); - - throughput.echoByteSeq(emptyBytes); - throughput.echoStringSeq(emptyStrings); - throughput.echoStructSeq(emptyStructs); - throughput.echoFixedSeq(emptyFixed); + throughput.sendByteSeq(emptyBytes); + throughput.sendStringSeq(emptyStrings); + throughput.sendStructSeq(emptyStructs); + throughput.sendFixedSeq(emptyFixed); + + throughput.recvByteSeq(); + throughput.recvStringSeq(); + throughput.recvStructSeq(); + throughput.recvFixedSeq(); + + throughput.echoByteSeq(emptyBytes); + throughput.echoStringSeq(emptyStrings); + throughput.echoStructSeq(emptyStructs); + throughput.echoFixedSeq(emptyFixed); } - throughput.endWarmup(); - + throughput.endWarmup(); + System.out.println(" ok"); } - menu(); + menu(); java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - char currentType = '1'; - int seqSize = ByteSeqSize.value; + char currentType = '1'; + int seqSize = ByteSeqSize.value; - // Initial ping to setup the connection. - throughput.ice_ping(); - + // Initial ping to setup the connection. + throughput.ice_ping(); + String line = null; do { @@ -158,280 +158,280 @@ public class Client extends Ice.Application break; } - long tmsec = System.currentTimeMillis(); - final int repetitions = 100; - - if(line.equals("1") || line.equals("2") || line.equals("3") || line.equals("4")) - { - 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 variable-length struct sequences"); - seqSize = StringDoubleSeqSize.value; - break; - } - - case '4': - { - System.out.println("using fixed-length struct sequences"); - seqSize = FixedSeqSize.value; - break; - } - } - } + long tmsec = System.currentTimeMillis(); + final int repetitions = 100; + + if(line.equals("1") || line.equals("2") || line.equals("3") || line.equals("4")) + { + 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 variable-length struct sequences"); + seqSize = StringDoubleSeqSize.value; + break; + } + + case '4': + { + System.out.println("using fixed-length struct sequences"); + seqSize = FixedSeqSize.value; + break; + } + } + } else if(line.equals("t") || line.equals("o") || line.equals("r") || line.equals("e")) { - char c = line.charAt(0); - - switch(c) - { - case 't': - case 'o': - { - System.out.print("sending"); - break; - } - - case 'r': - { - System.out.print("receiving"); - break; - } - - case 'e': - { - System.out.print("sending and receiving"); - break; - } - } - - 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(" variable-length struct"); - break; - } - - case '4': - { - System.out.print(" fixed-length struct"); - break; - } - } - - System.out.print(" sequences of size " + seqSize); - - if(c == 'o') - { - System.out.print(" as oneway"); - } - - System.out.println("..."); - - for(int i = 0; i < repetitions; ++i) - { - switch(currentType) - { - case '1': - { - switch(c) - { - case 't': - { - throughput.sendByteSeq(byteSeq); - break; - } - - case 'o': - { - throughputOneway.sendByteSeq(byteSeq); - break; - } - - case 'r': - { - throughput.recvByteSeq(); - break; - } - - case 'e': - { - throughput.echoByteSeq(byteSeq); - break; - } - } - break; - } - - case '2': - { - 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 '3': - { - 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; - } - - case '4': - { - switch(c) - { - case 't': - { - throughput.sendFixedSeq(fixedSeq); - break; - } - - case 'o': - { - throughputOneway.sendFixedSeq(fixedSeq); - break; - } - - case 'r': - { - throughput.recvFixedSeq(); - break; - } - - case 'e': - { - throughput.echoFixedSeq(fixedSeq); - break; - } - } - break; - } - } - } - - double dmsec = System.currentTimeMillis() - tmsec; - System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms"); - System.out.println("time per sequence: " + dmsec / repetitions + "ms"); - 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; - } - - case '4': - { - wireSize = 16; // Size of two ints and a double on the wire. - break; - } - } - double mbit = repetitions * seqSize * wireSize * 8.0 / dmsec / 1000.0; - if(c == 'e') - { - mbit *= 2; - } - System.out.println("throughput: " + new java.text.DecimalFormat("#.##").format(mbit) + "Mbps"); - } - else if(line.equals("s")) - { - throughput.shutdown(); - } - else if(line.equals("x")) + char c = line.charAt(0); + + switch(c) + { + case 't': + case 'o': + { + System.out.print("sending"); + break; + } + + case 'r': + { + System.out.print("receiving"); + break; + } + + case 'e': + { + System.out.print("sending and receiving"); + break; + } + } + + 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(" variable-length struct"); + break; + } + + case '4': + { + System.out.print(" fixed-length struct"); + break; + } + } + + System.out.print(" sequences of size " + seqSize); + + if(c == 'o') + { + System.out.print(" as oneway"); + } + + System.out.println("..."); + + for(int i = 0; i < repetitions; ++i) + { + switch(currentType) + { + case '1': + { + switch(c) + { + case 't': + { + throughput.sendByteSeq(byteSeq); + break; + } + + case 'o': + { + throughputOneway.sendByteSeq(byteSeq); + break; + } + + case 'r': + { + throughput.recvByteSeq(); + break; + } + + case 'e': + { + throughput.echoByteSeq(byteSeq); + break; + } + } + break; + } + + case '2': + { + 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 '3': + { + 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; + } + + case '4': + { + switch(c) + { + case 't': + { + throughput.sendFixedSeq(fixedSeq); + break; + } + + case 'o': + { + throughputOneway.sendFixedSeq(fixedSeq); + break; + } + + case 'r': + { + throughput.recvFixedSeq(); + break; + } + + case 'e': + { + throughput.echoFixedSeq(fixedSeq); + break; + } + } + break; + } + } + } + + double dmsec = System.currentTimeMillis() - tmsec; + System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms"); + System.out.println("time per sequence: " + dmsec / repetitions + "ms"); + 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; + } + + case '4': + { + wireSize = 16; // Size of two ints and a double on the wire. + break; + } + } + double mbit = repetitions * seqSize * wireSize * 8.0 / dmsec / 1000.0; + if(c == 'e') + { + mbit *= 2; + } + System.out.println("throughput: " + new java.text.DecimalFormat("#.##").format(mbit) + "Mbps"); + } + else if(line.equals("s")) + { + throughput.shutdown(); + } + else if(line.equals("x")) { // Nothing to do } |