KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > stests > manac > A_multi


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: A_multi.java,v 1.8 2003/12/03 13:01:20 coqp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.stests.manac;
27
28
29 /**
30  * This TestCase is a set of multithreaded clients accessing concurrently
31  * the set of accounts. For each test, an indicative Time (in millisec) is
32  * given, to have a rough idea of the relative time of the test case.
33  * (first value = CMP1, second value = CMP2)
34  */

35 public abstract class A_multi extends A_manac {
36
37     // default values
38
int accounts = 20; // 20 accounts (nb of pre-created accounts)
39
int delay = 0; // no delay added
40
int loops = 1; // 1 loop
41
int amount = 10; // withdraw value : 10 (initial value is 1000)
42
int threads = 2; // 2 threads
43
int checklevel = 2; // check accounts after every test
44
int timeout = 12; // 12 seconds
45

46     public A_multi(String JavaDoc name) {
47         super(name);
48     }
49
50     public int getAccounts() {
51         return accounts;
52     }
53
54     /*
55      * Simplest test with 2 threads : 1 loop, 2 threads, no rollback, no delay
56      * Time:
57      */

58     public void testBasic() throws Exception JavaDoc {
59         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
60     }
61
62     /*
63      * 2 threads with possible rollback
64      * Time:
65      */

66     public void testRb() throws Exception JavaDoc {
67         int accounts = 6;
68         int loops = 10;
69         int amount = 400;
70         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
71     }
72
73     /*
74      * add a delay
75      * Time:
76      */

77     public void testD3T3() throws Exception JavaDoc {
78         int accounts = 4;
79         int delay = 3;
80         int loops = 6;
81         int threads = 3;
82         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
83     }
84
85     /*
86      * 4 threads
87      * Time:
88      */

89     public void testT4() throws Exception JavaDoc {
90         int loops = 12;
91         int threads = 4;
92         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
93     }
94
95     /*
96      * 6 threads
97      * Time: 3,449 20,143 (or possible failure)
98      */

99     public void testT6() throws Exception JavaDoc {
100         int loops = 8;
101         int threads = 6;
102         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
103     }
104
105     /*
106      * 6 threads with collisions
107      * Time: 27,967 52,204
108      */

109     public void testCollT6() throws Exception JavaDoc {
110         int accounts = 4;
111         int threads = 6;
112         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
113     }
114
115     /*
116      * 8 threads
117      * Time: 73,842 failure
118      */

119     public void testT8() throws Exception JavaDoc {
120         int loops = 6;
121         int threads = 8;
122         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
123     }
124
125     /*
126      * 8 threads with many collisions
127      * Time: 42,465 42,846
128      */

129     public void testCollT8() throws Exception JavaDoc {
130         int accounts = 4;
131         int threads = 8;
132         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
133     }
134
135     /*
136      * 16 threads
137      * Time: 33,22 failure
138      */

139     public void testT16() throws Exception JavaDoc {
140         int threads = 16;
141         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
142     }
143
144
145     /*
146      * more threads again
147      * failure failure
148      */

149     public void testT30() throws Exception JavaDoc {
150         int threads = 30;
151         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
152     }
153
154
155     /*
156      * 4 threads and possible create
157      * Time: 3,706 3,227
158      */

159     public void testCreateT4() throws Exception JavaDoc {
160         int accounts = 200;
161         int loops = 12;
162         int threads = 4;
163         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
164     }
165
166     /*
167      * 2 threads with possible rollback and create
168      * Time: 3,601 7,146
169      */

170     public void testCreateRbT2() throws Exception JavaDoc {
171         int accounts = 100;
172         int loops = 10;
173         int amount = 444;
174         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
175     }
176
177     /*
178      * 4 threads with delay and possible create
179      * Time:
180      */

181     public void testCreateD2T4() throws Exception JavaDoc {
182         int accounts = 200;
183         int delay = 2;
184         int threads = 4;
185         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
186     }
187
188     /*
189      * 6 threads and possible create
190      * Time:
191      */

192     public void testCreateT6() throws Exception JavaDoc {
193         int accounts = 400;
194         int loops = 8;
195         int threads = 6;
196         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
197     }
198
199     /*
200      * 8 threads and possible create
201      * Time:
202      */

203     public void testCreateT8() throws Exception JavaDoc {
204         int accounts = 400;
205         int loops = 6;
206         int threads = 8;
207         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
208     }
209
210     /*
211      * 16 threads and possible create
212      * Time: 5,381 15,261
213      */

214     public void testCreateT16() throws Exception JavaDoc {
215         int accounts = 800;
216         int threads = 16;
217         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
218     }
219
220     /*
221      * 16 threads more loops
222      * Time: 14,431 14,239
223      */

224     public void testCreateD1T16() throws Exception JavaDoc {
225         int accounts = 300;
226         int delay = 1;
227         int threads = 16;
228         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
229     }
230
231     /*
232      * Test many create in parallell
233      */

234     public void testConcurrentCreate() throws Exception JavaDoc {
235         int accounts = 40;
236         int threads = 30;
237         int loops = 1;
238         int timeout = 18;
239         manac(accounts, delay, loops, amount, threads, checklevel, timeout);
240     }
241
242 }
243
Popular Tags