KickJava   Java API By Example, From Geeks To Geeks.

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


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 T1PassStringsTestCase
42    extends JBossTestCase
43 {
44    // Constants -----------------------------------------------------
45

46    // Attributes ----------------------------------------------------
47
private java.util.Properties JavaDoc cosnamingJndiProps;
48    String JavaDoc str10 = "0123456789";
49    String JavaDoc str100;
50    String JavaDoc str1000;
51    String JavaDoc str10000;
52
53    // Static --------------------------------------------------------
54

55    // Constructors --------------------------------------------------
56
public T1PassStringsTestCase(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       str100 = "";
67       for (int i = 0; i < 10; i++)
68          str100 = str100 + str10;
69
70       str1000 = "";
71       for (int i = 0; i < 10; i++)
72          str1000 = str1000 + str100;
73
74       str10000 = "";
75       for (int i = 0; i < 10; i++)
76          str10000 = str10000 + str1000;
77
78    }
79    
80    // Package --------------------------------------------------------
81

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

90    /**
91     * This tests the speed of JRMP sendString invocations
92     *
93     * @exception Exception
94     */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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