KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > util > collection > DListTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 //NOTE: Tabs are used instead of spaces for indentation.
25
// Make sure that your editor does not replace tabs with spaces.
26
// Set the tab length using your favourite editor to your
27
// visual preference.
28

29 /*
30  * Filename: TooManyTasksException.java
31  *
32  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
33  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
34  * All rights reserved.
35  *
36  * This software is the confidential and proprietary information
37  * of iPlanet/Sun Microsystems, Inc. ("Confidential Information").
38  * You shall not disclose such Confidential Information and shall
39  * use it only in accordance with the terms of the license
40  * agreement you entered into with iPlanet/Sun Microsystems.
41  */

42  
43 /**
44  * <BR> <I>$Source: /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/util/collection/DListTest.java,v $</I>
45  * @author $Author: tcfujii $
46  * @version $Revision: 1.3 $ $Date: 2005/12/25 04:12:11 $
47  */

48  
49 package com.sun.enterprise.util.collection;
50
51 import java.util.*;
52
53 public class DListTest {
54     
55     public static void main(String JavaDoc[] args)
56         throws Exception JavaDoc
57     {
58         
59         int count = 20;
60         long time=0, t1=0, t2 = 0;
61         String JavaDoc data = "SomeData_";
62
63         SortedArrayListBucket bucket = new SortedArrayListBucket();
64         for (int i=0; i<count; i+= 5) {
65             bucket.put(i, data + i);
66         }
67         
68         for (int i=1; i<count; i+= 3) {
69             bucket.put(i, data + i);
70         }
71         
72         for (int i=3; i<count; i+= 4) {
73             bucket.put(i, data + i);
74         }
75         
76         for (int i=-23; i<count; i+= 4) {
77             bucket.put(i, data + i);
78         }
79         IntEntry entry = null;
80         Iterator iter = bucket.entryIterator();
81         while (iter.hasNext()) {
82             entry = (IntEntry) iter.next();
83             System.out.println(entry);
84         }
85             
86         
87         t1 = System.currentTimeMillis();
88         for (int i=0; i<1000000; i++) {
89             for (int j=-25; j<25; j++) {
90                 bucket.get(j);
91             }
92         }
93         t2 = System.currentTimeMillis();
94         System.out.println("llist.remove(): " + ((t2 - t1) / 1000.0) + " seconds " + time);
95         //32.968
96
}
97     
98 }
Popular Tags