Source Code Cross Referenced for Client.java in  » Collaboration » JacORB » demo » benchmark » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » JacORB » demo.benchmark 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package demo.benchmark;
002:
003:        import java.io.*;
004:        import org.omg.CosNaming.*;
005:
006:        /**
007:         * A simple benchmark for remote invocations.
008:         * It takes the system clock right before and after 
009:         * method invocations. Originally adopted
010:         * from code by Christophe Warland
011:         */
012:
013:        public class Client {
014:
015:            public static void main(String args[]) {
016:                org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
017:                bench server = null;
018:
019:                try {
020:                    if (args.length > 0) {
021:                        try {
022:                            File f = new File(args[0]);
023:                            BufferedReader br = new BufferedReader(
024:                                    new FileReader(f));
025:                            String ior = br.readLine();
026:                            br.close();
027:                            server = benchHelper.narrow(orb
028:                                    .string_to_object(ior));
029:                        } catch (Exception e) {
030:                            e.printStackTrace();
031:                            System.exit(1);
032:                        }
033:
034:                    } else {
035:                        NamingContextExt nc = NamingContextExtHelper.narrow(orb
036:                                .resolve_initial_references("NameService"));
037:                        server = benchHelper.narrow(nc.resolve(nc
038:                                .to_name("benchmark")));
039:                    }
040:
041:                    System.out.print("     Ping                       [1]\n"
042:                            + "     Transfer array of int      [2]\n"
043:                            + "     Transfer array of byte     [3]\n"
044:                            + "     Transfer array of struct   [4]\n"
045:                            + "     Transfer array of string   [5]\n"
046:                            + "                                   \n"
047:                            + "     Auto mode     - Long! -    [auto]\n"
048:                            + "     EXIT                       [0]\n"
049:                            + "     --------------------------------\n"
050:                            + "         Your choice :          ");
051:
052:                    DataInput d = new DataInputStream(System.in);
053:                    String line;
054:
055:                    while ((line = d.readLine()) != null) {
056:                        if (line.equals("1")) {
057:                            System.out.print("     Number of loops : ");
058:                            int loop = new Integer(d.readLine()).intValue();
059:                            int nb = loop;
060:                            long startTime = 0;
061:                            long stopTime = 0;
062:
063:                            startTime = System.currentTimeMillis();
064:                            while (nb-- > 0)
065:                                server.ping();
066:
067:                            stopTime = System.currentTimeMillis();
068:
069:                            System.out.println(">>> Elapsed time = "
070:                                    + (stopTime - startTime) / 1000
071:                                    + " secs      avg time = ("
072:                                    + ((stopTime - startTime) / (float) loop)
073:                                    + ") msecs");
074:
075:                        } else if (line.equals("2")) {
076:                            System.out.print("     Number of loops : ");
077:                            int loop = new Integer(d.readLine()).intValue();
078:                            int nb = loop;
079:                            System.out.print("     Size of array : ");
080:                            int size = new Integer(d.readLine()).intValue();
081:                            int myInt[] = new int[size];
082:                            for (int si = 0; si < size; si++) {
083:                                myInt[si] = si;
084:                            }
085:
086:                            int ret_vals[] = null;
087:
088:                            long startTime = System.currentTimeMillis();
089:                            while (nb-- > 0)
090:                                ret_vals = server.intTransfer(myInt);
091:
092:                            // for(int i = 0; i < size; System.out.print(" " + ret_vals[i++]));
093:
094:                            long stopTime = System.currentTimeMillis();
095:                            System.out.println(">>> Elapsed time = "
096:                                    + (stopTime - startTime) / 1000
097:                                    + " secs      Average time = "
098:                                    + ((stopTime - startTime) / (float) loop)
099:                                    + " msecs");
100:
101:                        } else if (line.equals("3")) {
102:                            // byte arrays 
103:
104:                            System.out.print("     Number of loops : ");
105:                            int loop = new Integer(d.readLine()).intValue();
106:                            int nb = loop;
107:                            System.out.print("     Size of array : ");
108:                            int size = new Integer(d.readLine()).intValue();
109:                            byte mybytes[] = new byte[size];
110:
111:                            long startTime = System.currentTimeMillis();
112:                            while (nb-- > 0)
113:                                server.octetTransfer(mybytes);
114:
115:                            long stopTime = System.currentTimeMillis();
116:                            System.out.println(">>> Elapsed time = "
117:                                    + (stopTime - startTime) / 1000
118:                                    + " secs      Average time = "
119:                                    + ((stopTime - startTime) / (float) loop)
120:                                    + " msecs");
121:
122:                        } else if (line.equals("4")) {
123:                            // struct arrays 
124:
125:                            System.out.print("     Number of loops : ");
126:                            int loop = new Integer(d.readLine()).intValue();
127:                            int nb = loop;
128:                            System.out.print("     Array Size : ");
129:                            int size = new Integer(d.readLine()).intValue();
130:                            Struct myStruct[] = new Struct[size];
131:
132:                            for (int si = 0; si < size; si++)
133:                                myStruct[si] = new Struct();
134:
135:                            long startTime = System.currentTimeMillis();
136:                            while (nb-- > 0)
137:                                server.structTransfer(myStruct);
138:
139:                            long stopTime = System.currentTimeMillis();
140:                            System.out.println(">>> Elapsed time = "
141:                                    + (stopTime - startTime) / 1000
142:                                    + " secs      Average time = "
143:                                    + ((stopTime - startTime) / (float) loop)
144:                                    + " msecs");
145:
146:                        } else if (line.equals("5")) {
147:                            // string arrays 
148:
149:                            System.out.print("     Number of loops : ");
150:                            int loop = new Integer(d.readLine()).intValue();
151:                            int nb = loop;
152:                            System.out.print("     Array size: ");
153:                            int size = new Integer(d.readLine()).intValue();
154:                            String myString[] = new String[size];
155:
156:                            for (int si = 0; si < size; si++)
157:                                myString[si] = "testString";
158:
159:                            long startTime = System.currentTimeMillis();
160:                            while (nb-- > 0)
161:                                server.stringTransfer(myString);
162:
163:                            long stopTime = System.currentTimeMillis();
164:                            System.out.println(">>> Elapsed time = "
165:                                    + (stopTime - startTime) / 1000
166:                                    + " secs      Average time = "
167:                                    + ((stopTime - startTime) / (float) loop)
168:                                    + " msecs");
169:
170:                        } else if (line.equals("auto")) {
171:                            System.out.println("#### Entering auto-mode ####");
172:                            System.out.print("     Number of loops : ");
173:                            int loop = new Integer(d.readLine()).intValue();
174:                            int size = 1;
175:                            System.out
176:                                    .println("\n Results are average times in msecs for "
177:                                            + loop + " round trips\n");
178:                            System.out
179:                                    .println("  Array size     Ping    int[]  byte[]  struct[]   string[]");
180:                            System.out
181:                                    .println(" ============= ======== ====== ======= ========== =========");
182:
183:                            for (int i = 0; i < 6; i++) {
184:                                System.out.print("\t" + size);
185:                                int myInt[] = new int[size];
186:                                byte myByte[] = new byte[size];
187:                                Struct myStruct[] = new Struct[size];
188:                                String myString[] = new String[size];
189:                                for (int si = 0; si < size; si++) {
190:                                    myStruct[si] = new Struct();
191:                                    myInt[si] = si;
192:                                    myString[si] = "testString";
193:                                }
194:
195:                                long startTime = System.currentTimeMillis();
196:
197:                                int nb = loop;
198:                                while (nb-- > 0)
199:                                    server.ping();
200:
201:                                long stopTime = System.currentTimeMillis();
202:                                System.out
203:                                        .print("\t"
204:                                                + ((stopTime - startTime) / (float) loop));
205:                                startTime = System.currentTimeMillis();
206:
207:                                nb = loop;
208:                                while (nb-- > 0)
209:                                    server.intTransfer(myInt);
210:
211:                                stopTime = System.currentTimeMillis();
212:                                System.out
213:                                        .print("\t"
214:                                                + ((stopTime - startTime) / (float) loop));
215:
216:                                startTime = System.currentTimeMillis();
217:                                nb = loop;
218:                                while (nb-- > 0)
219:                                    server.octetTransfer(myByte);
220:                                stopTime = System.currentTimeMillis();
221:                                System.out
222:                                        .print("\t"
223:                                                + ((stopTime - startTime) / (float) loop));
224:
225:                                startTime = System.currentTimeMillis();
226:                                nb = loop;
227:                                while (nb-- > 0)
228:                                    server.structTransfer(myStruct);
229:                                stopTime = System.currentTimeMillis();
230:                                System.out
231:                                        .print("\t"
232:                                                + ((stopTime - startTime) / (float) loop));
233:
234:                                startTime = System.currentTimeMillis();
235:                                nb = loop;
236:                                while (nb-- > 0)
237:                                    server.stringTransfer(myString);
238:                                stopTime = System.currentTimeMillis();
239:                                System.out
240:                                        .print("\t"
241:                                                + ((stopTime - startTime) / (float) loop));
242:
243:                                System.out.println();
244:                                size = size * 10;
245:                            }
246:                            System.out
247:                                    .println("\n#### Exiting auto-mode ####\n");
248:                        } else if (line.equals("0")) {
249:                            System.out.println("\nExiting ...");
250:                            orb.shutdown(true);
251:                            return;
252:                            //System.exit(0);
253:                        }
254:                        System.out
255:                                .print("     Ping [1]   Array of int [2]  Array of byte [3] "
256:                                        + "Array of struct [4] : ");
257:
258:                    } // while
259:                } catch (Exception e) {
260:                    System.out.println("### Exception !!! ### \n");
261:                    e.printStackTrace();
262:                }
263:                orb.shutdown(true);
264:                // System.exit(0);
265:            }
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.