KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > iiopperf > test > T5PassStringArraysTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.iiopperf.test;
23
24
25 import javax.ejb.*;
26 import javax.naming.*;
27 import javax.rmi.PortableRemoteObject JavaDoc;
28
29 import org.jboss.test.iiopperf.interfaces.*;
30
31 import junit.framework.Test;
32 import junit.framework.TestCase;
33 import junit.framework.TestSuite;
34 import org.jboss.test.JBossTestCase;
35
36
37 /**
38  * @author Francisco.Reverbel@jboss.org
39  * @version $Revision: 37406 $
40  */

41 public class T5PassStringArraysTestCase
42    extends JBossTestCase
43 {
44    // Constants -----------------------------------------------------
45

46    // Attributes ----------------------------------------------------
47
private java.util.Properties JavaDoc cosnamingJndiProps;
48    String JavaDoc[] sa10;
49    String JavaDoc[] sa100;
50    String JavaDoc[] sa1000;
51    String JavaDoc[] sa10000;
52    
53    // Static --------------------------------------------------------
54

55    // Constructors --------------------------------------------------
56
public T5PassStringArraysTestCase(String JavaDoc name)
57        throws java.io.IOException JavaDoc
58    {
59       super(name);
60       java.net.URL JavaDoc url;
61
62       url = ClassLoader.getSystemResource("cosnaming.jndi.properties");
63       cosnamingJndiProps = new java.util.Properties JavaDoc();
64       cosnamingJndiProps.load(url.openStream());
65
66       sa10 = new String JavaDoc[10];
67       for (int i = 0; i < sa10.length; i++)
68          sa10[i] = "" + i;
69
70       sa100 = new String JavaDoc[100];
71       for (int i = 0; i < sa100.length; i++)
72          sa100[i] = "" + i;
73
74       sa1000 = new String JavaDoc[1000];
75       for (int i = 0; i < sa1000.length; i++)
76          sa1000[i] = "" + i;
77
78       sa10000 = new String JavaDoc[10000];
79       for (int i = 0; i < sa10000.length; i++)
80          sa10000[i] = "" + i;
81    }
82    
83    // Package --------------------------------------------------------
84

85    InitialContext getInitialContext(java.util.Properties JavaDoc jndiProps)
86        throws Exception JavaDoc
87    {
88       return new InitialContext(jndiProps);
89    }
90
91    // Public --------------------------------------------------------
92

93    /**
94     * This tests the speed of JRMP sendStringArray invocations
95     *
96     * @exception Exception
97     */

98    public void testJRMPSendStringArray10()
99       throws Exception JavaDoc
100    {
101       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
102             getInitialContext().lookup(SessionHome.JNDI_NAME),
103             SessionHome.class);
104       Session session = home.create();
105       int n = getIterationCount();
106       long start = System.currentTimeMillis();
107       for (int i = 0 ; i < n; i++)
108       {
109          session.sendStringArray(sa10);
110       }
111       long end = System.currentTimeMillis();
112       getLog().info("JRMP sendStringArray(10): " +
113                     ((end - start) / (double)n) + " ms/call");
114    }
115    
116    /**
117     * This tests the speed of IIOP sendStringArray invocations
118     *
119     * @exception Exception
120     */

121    public void testIIOPSendStringArray10()
122       throws Exception JavaDoc
123    {
124       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
125             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
126             SessionHome.class);
127       Session session = home.create();
128       int n = getIterationCount();
129       long start = System.currentTimeMillis();
130       for (int i = 0 ; i < n; i++)
131       {
132          session.sendStringArray(sa10);
133       }
134       long end = System.currentTimeMillis();
135       getLog().info("IIOP sendStringArray(10): " +
136                     ((end - start) / (double)n) + " ms/call");
137    }
138    
139    /**
140     * This tests the speed of JRMP receiveStringArray invocations
141     *
142     * @exception Exception
143     */

144    public void testJRMPReceiveStringArray10()
145       throws Exception JavaDoc
146    {
147       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
148             getInitialContext().lookup(SessionHome.JNDI_NAME),
149             SessionHome.class);
150       Session session = home.create();
151       session.sendStringArray(sa10);
152       int n = getIterationCount();
153       long start = System.currentTimeMillis();
154       for (int i = 0 ; i < n; i++)
155       {
156          session.receiveStringArray();
157       }
158       long end = System.currentTimeMillis();
159       getLog().info("JRMP receiveStringArray(10): " +
160                     ((end - start) / (double)n) + " ms/call");
161    }
162    
163    /**
164     * This tests the speed of IIOP receiveStringArray invocations
165     *
166     * @exception Exception
167     */

168    public void testIIOPReceiveStringArray10()
169       throws Exception JavaDoc
170    {
171       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
172             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
173             SessionHome.class);
174       Session session = home.create();
175       session.sendStringArray(sa10);
176       int n = getIterationCount();
177       long start = System.currentTimeMillis();
178       for (int i = 0 ; i < n; i++)
179       {
180          session.receiveStringArray();
181       }
182       long end = System.currentTimeMillis();
183       getLog().info("IIOP receiveStringArray(10): " +
184                     ((end - start) / (double)n) + " ms/call");
185    }
186    
187    /**
188     * This tests the speed of JRMP sendReceiveStringArray invocations
189     *
190     * @exception Exception
191     */

192    public void testJRMPSendReceiveStringArray10()
193       throws Exception JavaDoc
194    {
195       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
196             getInitialContext().lookup(SessionHome.JNDI_NAME),
197             SessionHome.class);
198       Session session = home.create();
199       int n = getIterationCount();
200       long start = System.currentTimeMillis();
201       for (int i = 0 ; i < n; i++)
202       {
203          session.sendReceiveStringArray(sa10);
204       }
205       long end = System.currentTimeMillis();
206       getLog().info("JRMP sendReceiveStringArray(10): " +
207                     ((end - start) / (double)n) + " ms/call");
208    }
209    
210    /**
211     * This tests the speed of IIOP sendReceiveStringArray invocations
212     *
213     * @exception Exception
214     */

215    public void testIIOPSendReceiveStringArray10()
216       throws Exception JavaDoc
217    {
218       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
219             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
220             SessionHome.class);
221       Session session = home.create();
222       int n = getIterationCount();
223       long start = System.currentTimeMillis();
224       for (int i = 0 ; i < n; i++)
225       {
226          session.sendReceiveStringArray(sa10);
227       }
228       long end = System.currentTimeMillis();
229       getLog().info("IIOP sendReceiveStringArray(10): " +
230                     ((end - start) / (double)n) + " ms/call");
231    }
232
233    /**
234     * This tests the speed of JRMP sendStringArray invocations
235     *
236     * @exception Exception
237     */

238    public void testJRMPSendStringArray100()
239       throws Exception JavaDoc
240    {
241       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
242             getInitialContext().lookup(SessionHome.JNDI_NAME),
243             SessionHome.class);
244       Session session = home.create();
245       int n = getIterationCount();
246       long start = System.currentTimeMillis();
247       for (int i = 0 ; i < n; i++)
248       {
249          session.sendStringArray(sa100);
250       }
251       long end = System.currentTimeMillis();
252       getLog().info("JRMP sendStringArray(100): " +
253                     ((end - start) / (double)n) + " ms/call");
254    }
255    
256    /**
257     * This tests the speed of IIOP sendStringArray invocations
258     *
259     * @exception Exception
260     */

261    public void testIIOPSendStringArray100()
262       throws Exception JavaDoc
263    {
264       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
265             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
266             SessionHome.class);
267       Session session = home.create();
268       int n = getIterationCount();
269       long start = System.currentTimeMillis();
270       for (int i = 0 ; i < n; i++)
271       {
272          session.sendStringArray(sa100);
273       }
274       long end = System.currentTimeMillis();
275       getLog().info("IIOP sendStringArray(100): " +
276                     ((end - start) / (double)n) + " ms/call");
277    }
278    
279    /**
280     * This tests the speed of JRMP receiveStringArray invocations
281     *
282     * @exception Exception
283     */

284    public void testJRMPReceiveStringArray100()
285       throws Exception JavaDoc
286    {
287       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
288             getInitialContext().lookup(SessionHome.JNDI_NAME),
289             SessionHome.class);
290       Session session = home.create();
291       session.sendStringArray(sa100);
292       int n = getIterationCount();
293       long start = System.currentTimeMillis();
294       for (int i = 0 ; i < n; i++)
295       {
296          session.receiveStringArray();
297       }
298       long end = System.currentTimeMillis();
299       getLog().info("JRMP receiveStringArray(100): " +
300                     ((end - start) / (double)n) + " ms/call");
301    }
302    
303    /**
304     * This tests the speed of IIOP receiveStringArray invocations
305     *
306     * @exception Exception
307     */

308    public void testIIOPReceiveStringArray100()
309       throws Exception JavaDoc
310    {
311       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
312             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
313             SessionHome.class);
314       Session session = home.create();
315       session.sendStringArray(sa100);
316       int n = getIterationCount();
317       long start = System.currentTimeMillis();
318       for (int i = 0 ; i < n; i++)
319       {
320          session.receiveStringArray();
321       }
322       long end = System.currentTimeMillis();
323       getLog().info("IIOP receiveStringArray(100): " +
324                     ((end - start) / (double)n) + " ms/call");
325    }
326    
327    /**
328     * This tests the speed of JRMP sendReceiveStringArray invocations
329     *
330     * @exception Exception
331     */

332    public void testJRMPSendReceiveStringArray100()
333       throws Exception JavaDoc
334    {
335       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
336             getInitialContext().lookup(SessionHome.JNDI_NAME),
337             SessionHome.class);
338       Session session = home.create();
339       int n = getIterationCount();
340       long start = System.currentTimeMillis();
341       for (int i = 0 ; i < n; i++)
342       {
343          session.sendReceiveStringArray(sa100);
344       }
345       long end = System.currentTimeMillis();
346       getLog().info("JRMP sendReceiveStringArray(100): " +
347                     ((end - start) / (double)n) + " ms/call");
348    }
349    
350    /**
351     * This tests the speed of IIOP sendReceiveStringArray invocations
352     *
353     * @exception Exception
354     */

355    public void testIIOPSendReceiveStringArray100()
356       throws Exception JavaDoc
357    {
358       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
359             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
360             SessionHome.class);
361       Session session = home.create();
362       int n = getIterationCount();
363       long start = System.currentTimeMillis();
364       for (int i = 0 ; i < n; i++)
365       {
366          session.sendReceiveStringArray(sa100);
367       }
368       long end = System.currentTimeMillis();
369       getLog().info("IIOP sendReceiveStringArray(100): " +
370                     ((end - start) / (double)n) + " ms/call");
371    }
372
373    /**
374     * This tests the speed of JRMP sendStringArray invocations
375     *
376     * @exception Exception
377     */

378    public void testJRMPSendStringArray1000()
379       throws Exception JavaDoc
380    {
381       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
382             getInitialContext().lookup(SessionHome.JNDI_NAME),
383             SessionHome.class);
384       Session session = home.create();
385       int n = getIterationCount();
386       long start = System.currentTimeMillis();
387       for (int i = 0 ; i < n; i++)
388       {
389          session.sendStringArray(sa1000);
390       }
391       long end = System.currentTimeMillis();
392       getLog().info("JRMP sendStringArray(1000): " +
393                     ((end - start) / (double)n) + " ms/call");
394    }
395    
396    /**
397     * This tests the speed of IIOP sendStringArray invocations
398     *
399     * @exception Exception
400     */

401    public void testIIOPSendStringArray1000()
402       throws Exception JavaDoc
403    {
404       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
405             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
406             SessionHome.class);
407       Session session = home.create();
408       int n = getIterationCount();
409       long start = System.currentTimeMillis();
410       for (int i = 0 ; i < n; i++)
411       {
412          session.sendStringArray(sa1000);
413       }
414       long end = System.currentTimeMillis();
415       getLog().info("IIOP sendStringArray(1000): " +
416                     ((end - start) / (double)n) + " ms/call");
417    }
418    
419    /**
420     * This tests the speed of JRMP receiveStringArray invocations
421     *
422     * @exception Exception
423     */

424    public void testJRMPReceiveStringArray1000()
425       throws Exception JavaDoc
426    {
427       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
428             getInitialContext().lookup(SessionHome.JNDI_NAME),
429             SessionHome.class);
430       Session session = home.create();
431       session.sendStringArray(sa1000);
432       int n = getIterationCount();
433       long start = System.currentTimeMillis();
434       for (int i = 0 ; i < n; i++)
435       {
436          session.receiveStringArray();
437       }
438       long end = System.currentTimeMillis();
439       getLog().info("JRMP receiveStringArray(1000): " +
440                     ((end - start) / (double)n) + " ms/call");
441    }
442    
443    /**
444     * This tests the speed of IIOP receiveStringArray invocations
445     *
446     * @exception Exception
447     */

448    public void testIIOPReceiveStringArray1000()
449       throws Exception JavaDoc
450    {
451       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
452             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
453             SessionHome.class);
454       Session session = home.create();
455       session.sendStringArray(sa1000);
456       int n = getIterationCount();
457       long start = System.currentTimeMillis();
458       for (int i = 0 ; i < n; i++)
459       {
460          session.receiveStringArray();
461       }
462       long end = System.currentTimeMillis();
463       getLog().info("IIOP receiveStringArray(1000): " +
464                     ((end - start) / (double)n) + " ms/call");
465    }
466    
467    /**
468     * This tests the speed of JRMP sendReceiveStringArray invocations
469     *
470     * @exception Exception
471     */

472    public void testJRMPSendReceiveStringArray1000()
473       throws Exception JavaDoc
474    {
475       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
476             getInitialContext().lookup(SessionHome.JNDI_NAME),
477             SessionHome.class);
478       Session session = home.create();
479       int n = getIterationCount();
480       long start = System.currentTimeMillis();
481       for (int i = 0 ; i < n; i++)
482       {
483          session.sendReceiveStringArray(sa1000);
484       }
485       long end = System.currentTimeMillis();
486       getLog().info("JRMP sendReceiveStringArray(1000): " +
487                     ((end - start) / (double)n) + " ms/call");
488    }
489    
490    /**
491     * This tests the speed of IIOP sendReceiveStringArray invocations
492     *
493     * @exception Exception
494     */

495    public void testIIOPSendReceiveStringArray1000()
496       throws Exception JavaDoc
497    {
498       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
499             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
500             SessionHome.class);
501       Session session = home.create();
502       int n = getIterationCount();
503       long start = System.currentTimeMillis();
504       for (int i = 0 ; i < n; i++)
505       {
506          session.sendReceiveStringArray(sa1000);
507       }
508       long end = System.currentTimeMillis();
509       getLog().info("IIOP sendReceiveStringArray(1000): " +
510                     ((end - start) / (double)n) + " ms/call");
511    }
512
513    /**
514     * This tests the speed of JRMP sendStringArray invocations
515     *
516     * @exception Exception
517     */

518    public void testJRMPSendStringArray10000()
519       throws Exception JavaDoc
520    {
521       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
522             getInitialContext().lookup(SessionHome.JNDI_NAME),
523             SessionHome.class);
524       Session session = home.create();
525       int n = getIterationCount();
526       long start = System.currentTimeMillis();
527       for (int i = 0 ; i < n; i++)
528       {
529          session.sendStringArray(sa10000);
530       }
531       long end = System.currentTimeMillis();
532       getLog().info("JRMP sendStringArray(10000): " +
533                     ((end - start) / (double)n) + " ms/call");
534    }
535    
536    /**
537     * This tests the speed of IIOP sendStringArray invocations
538     *
539     * @exception Exception
540     */

541    public void testIIOPSendStringArray10000()
542       throws Exception JavaDoc
543    {
544       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
545             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
546             SessionHome.class);
547       Session session = home.create();
548       int n = getIterationCount();
549       long start = System.currentTimeMillis();
550       for (int i = 0 ; i < n; i++)
551       {
552          session.sendStringArray(sa10000);
553       }
554       long end = System.currentTimeMillis();
555       getLog().info("IIOP sendStringArray(10000): " +
556                     ((end - start) / (double)n) + " ms/call");
557    }
558    
559    /**
560     * This tests the speed of JRMP receiveStringArray invocations
561     *
562     * @exception Exception
563     */

564    public void testJRMPReceiveStringArray10000()
565       throws Exception JavaDoc
566    {
567       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
568             getInitialContext().lookup(SessionHome.JNDI_NAME),
569             SessionHome.class);
570       Session session = home.create();
571       session.sendStringArray(sa10000);
572       int n = getIterationCount();
573       long start = System.currentTimeMillis();
574       for (int i = 0 ; i < n; i++)
575       {
576          session.receiveStringArray();
577       }
578       long end = System.currentTimeMillis();
579       getLog().info("JRMP receiveStringArray(10000): " +
580                     ((end - start) / (double)n) + " ms/call");
581    }
582    
583    /**
584     * This tests the speed of IIOP receiveStringArray invocations
585     *
586     * @exception Exception
587     */

588    public void testIIOPReceiveStringArray10000()
589       throws Exception JavaDoc
590    {
591       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
592             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
593             SessionHome.class);
594       Session session = home.create();
595       session.sendStringArray(sa10000);
596       int n = getIterationCount();
597       long start = System.currentTimeMillis();
598       for (int i = 0 ; i < n; i++)
599       {
600          session.receiveStringArray();
601       }
602       long end = System.currentTimeMillis();
603       getLog().info("IIOP receiveStringArray(10000): " +
604                     ((end - start) / (double)n) + " ms/call");
605    }
606    
607    /**
608     * This tests the speed of JRMP sendReceiveStringArray invocations
609     *
610     * @exception Exception
611     */

612    public void testJRMPSendReceiveStringArray10000()
613       throws Exception JavaDoc
614    {
615       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
616             getInitialContext().lookup(SessionHome.JNDI_NAME),
617             SessionHome.class);
618       Session session = home.create();
619       int n = getIterationCount();
620       long start = System.currentTimeMillis();
621       for (int i = 0 ; i < n; i++)
622       {
623          session.sendReceiveStringArray(sa10000);
624       }
625       long end = System.currentTimeMillis();
626       getLog().info("JRMP sendReceiveStringArray(10000): " +
627                     ((end - start) / (double)n) + " ms/call");
628    }
629    
630    /**
631     * This tests the speed of IIOP sendReceiveStringArray invocations
632     *
633     * @exception Exception
634     */

635    public void testIIOPSendReceiveStringArray10000()
636       throws Exception JavaDoc
637    {
638       SessionHome home = (SessionHome)PortableRemoteObject.narrow(
639             getInitialContext(cosnamingJndiProps).lookup(SessionHome.JNDI_NAME),
640             SessionHome.class);
641       Session session = home.create();
642       int n = getIterationCount();
643       long start = System.currentTimeMillis();
644       for (int i = 0 ; i < n; i++)
645       {
646          session.sendReceiveStringArray(sa10000);
647       }
648       long end = System.currentTimeMillis();
649       getLog().info("IIOP sendReceiveStringArray(10000): " +
650                     ((end - start) / (double)n) + " ms/call");
651    }
652
653    public static Test suite() throws Exception JavaDoc
654    {
655       return getDeploySetup(T5PassStringArraysTestCase.class, "iiopperf.jar");
656    }
657
658 }
659
Popular Tags