KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26 import javax.ejb.*;
27 import javax.naming.*;
28 import javax.rmi.PortableRemoteObject JavaDoc;
29
30 import org.jboss.test.iiopperf.interfaces.*;
31
32 import junit.framework.Test;
33 import junit.framework.TestCase;
34 import junit.framework.TestSuite;
35 import org.jboss.test.JBossTestCase;
36
37
38 /**
39  * @author Francisco.Reverbel@jboss.org
40  * @version $Revision: 37406 $
41  */

42 public class T8PassMapsTestCase
43    extends JBossTestCase
44 {
45    // Constants -----------------------------------------------------
46

47    // Attributes ----------------------------------------------------
48
private java.util.Properties JavaDoc cosnamingJndiProps;
49    Map JavaDoc m10;
50    Map JavaDoc m100;
51    Map JavaDoc m1000;
52    Map JavaDoc m10000;
53    
54    // Static --------------------------------------------------------
55

56    // Constructors --------------------------------------------------
57
public T8PassMapsTestCase(String JavaDoc name)
58        throws java.io.IOException JavaDoc
59    {
60       super(name);
61       java.net.URL JavaDoc url;
62
63       url = ClassLoader.getSystemResource("cosnaming.jndi.properties");
64       cosnamingJndiProps = new java.util.Properties JavaDoc();
65       cosnamingJndiProps.load(url.openStream());
66
67       m10 = new HashMap JavaDoc(10);
68       for (int i = 0; i < 10; i++)
69          m10.put(new Integer JavaDoc(i), new Foo(i, "This is serializable #" + i));
70
71       m100 = new HashMap JavaDoc(100);
72       for (int i = 0; i < 100; i++)
73          m100.put(new Integer JavaDoc(i), new Foo(i, "This is serializable #" + i));
74
75       m1000 = new HashMap JavaDoc(1000);
76       for (int i = 0; i < 1000; i++)
77          m1000.put(new Integer JavaDoc(i), new Foo(i, "This is serializable #" + i));
78
79       m10000 = new HashMap JavaDoc(10000);
80       for (int i = 0; i < 10000; i++)
81          m10000.put(new Integer JavaDoc(i), new Foo(i, "This is serializable #" + i));
82
83    }
84    
85    // Package --------------------------------------------------------
86

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

95    /**
96     * This tests the speed of JRMP sendMap invocations
97     *
98     * @exception Exception
99     */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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