1 package demo.benchmark; 2 3 import java.io.*; 4 import org.omg.CosNaming.*; 5 6 public class OctetClient 7 { 8 9 public static void main(String args[]) 10 { 11 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); 12 octetBench server = null; 13 14 try 15 { 16 int start = 500; 17 int stop = 51000; 18 int step = 500; 19 int LOOPS = 100; 20 21 NamingContextExt nc = 22 NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); 23 24 server = 25 octetBenchHelper.narrow(nc.resolve(nc.to_name("octet_benchmark"))); 26 27 System.out.println("** Octet IN tests **"); 28 29 long startTime = 0; 30 long stopTime = 0; 31 int nb = LOOPS; 32 33 for( int i = start; i < stop; i += step ) 34 { 35 nb = LOOPS; 36 byte test[] = new byte[i]; 37 38 startTime = System.currentTimeMillis(); 39 while (nb-- > 0) 40 { 41 server.opOctetSeqIn( test ); 42 } 43 44 stopTime = System.currentTimeMillis(); 45 System.out.println( i + "\t" + ( (stopTime - startTime)/ (float)LOOPS)); 46 } 47 48 System.out.println("** Octet INOut tests **"); 49 demo.benchmark.OctetSeqHolder holder = new demo.benchmark.OctetSeqHolder(); 50 51 for( int i = start; i < stop; i += step ) 52 { 53 nb = LOOPS; 54 holder.value = new byte[i]; 55 56 startTime = System.currentTimeMillis(); 57 while (nb-- > 0) 58 { 59 server.opOctetSeqInOut( holder ); 60 } 61 62 stopTime = System.currentTimeMillis(); 63 System.out.println( i + "\t" + ( (stopTime - startTime)/ (float)LOOPS)); 64 } 65 66 67 68 } 69 catch (Exception e) 70 { 71 System.out.println("### Exception !!! ### \n"); 72 e.printStackTrace(); 73 } 74 orb.shutdown( true ); 75 } 77 } 78 79 80 | Popular Tags |