KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > BasicPerformanceTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.source;
21
22 import java.io.IOException JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.Enumeration JavaDoc;
26 import java.util.HashSet JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.StringTokenizer JavaDoc;
29 import java.util.TreeSet JavaDoc;
30 import java.util.jar.JarEntry JavaDoc;
31 import java.util.jar.JarFile JavaDoc;
32 import java.util.zip.ZipEntry JavaDoc;
33 import junit.framework.*;
34 import org.netbeans.modules.classfile.ClassFile;
35
36 /** Tests for basic JDK operations
37  *
38  * @author Petr Hrebejk
39  */

40 public class BasicPerformanceTest extends TestCase {
41     
42                 
43     public BasicPerformanceTest(String JavaDoc testName) {
44         super(testName);
45     }
46
47     protected void setUp() throws Exception JavaDoc {
48     }
49
50     protected void tearDown() throws Exception JavaDoc {
51     }
52     
53     
54 // public void testClassfileSizes() throws Exception {
55
//
56
// StopWatch swatch = new StopWatch();
57
//
58
// JarFile jar = TestUtil.getTestJarFile();
59
//
60
// int size = 0;
61
//
62
//
63
// ArrayList classfiles = new ArrayList();
64
// for( Enumeration e = jar.entries(); e.hasMoreElements(); ) {
65
// ZipEntry ze = (ZipEntry)e.nextElement();
66
// if ( !ze.isDirectory() ) {
67
// try {
68
// ClassFile cf = new ClassFile( jar.getInputStream( ze ) );
69
// // size += ScannerUtils.sizeOf( cf );
70
// classfiles.add( cf );
71
// }
72
// catch( IOException ex ) {
73
// // Ignore
74
// }
75
//
76
// }
77
// }
78
//
79
// swatch.stop( "Got classes " + size );
80
//
81
//
82
// }
83
//
84
// public void testNameCounts() throws Exception {
85
//
86
// JarFile jar = TestUtil.getTestJarFile();
87
//
88
// StopWatch swatch = new StopWatch();
89
// Enumeration<JarEntry> entries = jar.entries();
90
// ArrayList<String> names = new ArrayList<String>();
91
// while( entries.hasMoreElements() ) {
92
// names.add( entries.nextElement().getName() );
93
// }
94
// swatch.stop( "Got enries " + names.size() );
95
//
96
// HashSet<String> distinct = new HashSet<String>();
97
// swatch.start();
98
// for( String name : names ) {
99
// distinct.addAll( parseName( name ) );
100
// }
101
// swatch.stop( "Got distinct strings " + distinct.size() );
102
//
103
//// for( String name : distinct ) {
104
//// System.out.println( name );
105
//// }
106
//
107
// }
108
//
109
// private List<String> parseName( String str ) {
110
//
111
// List result = new ArrayList();
112
//
113
// StringTokenizer strtok = new StringTokenizer( str, "/$" );
114
// while( strtok.hasMoreTokens() ) {
115
// result.add( strtok.nextToken() );
116
// }
117
//
118
// return result;
119
// }
120
//
121
// public void testGetJarEntries() throws Exception {
122
//
123
// JarFile jar = TestUtil.getTestJarFile();
124
//
125
// StopWatch swatch = new StopWatch();
126
// Enumeration<JarEntry> entries = jar.entries();
127
// ArrayList<String> names = new ArrayList<String>();
128
// while( entries.hasMoreElements() ) {
129
// names.add( entries.nextElement().getName() );
130
// }
131
// swatch.stop( "Got enries" );
132
//
133
// swatch.start();
134
// ArrayList<String> al = new ArrayList<String>( names );
135
// Collections.sort( al );
136
// swatch.stop( "sort using array list" );
137
//
138
// swatch.start();
139
// TreeSet<String> ts = new TreeSet<String>( names );
140
// while( entries.hasMoreElements() ) {
141
// ts.add( entries.nextElement().getName() );
142
// }
143
// swatch.stop( "sort using tree set" );
144
//
145
// swatch.start();
146
//
147
// /*
148
// HashMap<String> packages = new HashSet<String>();
149
// for( String name : names ) {
150
// String pn = name.substring( 0, name.lastIndexOf( "/" ) ); // .replace( '/', '.' );
151
// if ( !packages.contains( pn ) ) {
152
// packages.add( pn );
153
// }
154
//
155
// }
156
// swatch.stop( "got packages" );
157
// */
158
//
159
//
160
// }
161

162 }
163
Popular Tags