1 /*2 * The contents of this file are subject to the terms of the Common Development3 * and Distribution License (the License). You may not use this file except in4 * compliance with the License.5 *6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html7 * or http://www.netbeans.org/cddl.txt.8 *9 * When distributing Covered Code, include this CDDL Header Notice in each file10 * and include the License file at http://www.netbeans.org/cddl.txt.11 * If applicable, add the following below the CDDL Header, with the fields12 * 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 Original16 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun17 * Microsystems, Inc. All Rights Reserved.18 */19 20 package org.netbeans.modules.java.source;21 22 import java.io.IOException ;23 import java.util.ArrayList ;24 import java.util.Collections ;25 import java.util.Enumeration ;26 import java.util.HashSet ;27 import java.util.List ;28 import java.util.StringTokenizer ;29 import java.util.TreeSet ;30 import java.util.jar.JarEntry ;31 import java.util.jar.JarFile ;32 import java.util.zip.ZipEntry ;33 import junit.framework.*;34 import org.netbeans.modules.classfile.ClassFile;35 36 /** Tests for basic JDK operations37 *38 * @author Petr Hrebejk39 */40 public class BasicPerformanceTest extends TestCase {41 42 43 public BasicPerformanceTest(String testName) {44 super(testName);45 }46 47 protected void setUp() throws Exception {48 }49 50 protected void tearDown() throws Exception {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 // // Ignore74 // }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