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