Log message changed. - Test added for navigator.
1.1 --- a/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberPanelUI.java
1.2 +++ b/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberPanelUI.java
1.3 @@ -186,7 +186,9 @@
1.4 final long tm1 = lastShowWaitNodeTime;
1.5 if (tm1 != -1) {
1.6 lastShowWaitNodeTime = -1;
1.7 - PERF_LOG.fine(String.format("ClassMemberPanelUI refresh took: %d ms", (tm2 - tm1))); //NOI18N
1.8 + PERF_LOG.log(Level.FINE,
1.9 + String.format("ClassMemberPanelUI refresh took: %d ms", (tm2 - tm1)),
1.10 + new Object[] { description.getFileObject().getName(), (tm2 - tm1) });
1.11 }
1.12 }
1.13 }
2.1 --- a/performance/nbproject/project.xml
2.2 +++ b/performance/nbproject/project.xml
2.3 @@ -120,6 +120,18 @@
2.4 <test-type>
2.5 <name>unit</name>
2.6 <test-dependency>
2.7 + <code-name-base>org.netbeans.modules.java.source</code-name-base>
2.8 + <compile-dependency/>
2.9 + </test-dependency>
2.10 + <test-dependency>
2.11 + <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
2.12 + <compile-dependency/>
2.13 + </test-dependency>
2.14 + <test-dependency>
2.15 + <code-name-base>org.netbeans.modules.projectui</code-name-base>
2.16 + <compile-dependency/>
2.17 + </test-dependency>
2.18 + <test-dependency>
2.19 <code-name-base>org.openide.filesystems</code-name-base>
2.20 <compile-dependency/>
2.21 </test-dependency>
3.1 new file mode 100644
3.2 --- /dev/null
3.3 +++ b/performance/test/unit/src/org/netbeans/performance/scanning/JavaNavigatorPerfTest.java
3.4 @@ -0,0 +1,176 @@
3.5 +/*
3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3.7 + *
3.8 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3.9 + *
3.10 + * The contents of this file are subject to the terms of either the GNU
3.11 + * General Public License Version 2 only ("GPL") or the Common
3.12 + * Development and Distribution License("CDDL") (collectively, the
3.13 + * "License"). You may not use this file except in compliance with the
3.14 + * License. You can obtain a copy of the License at
3.15 + * http://www.netbeans.org/cddl-gplv2.html
3.16 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
3.17 + * specific language governing permissions and limitations under the
3.18 + * License. When distributing the software, include this License Header
3.19 + * Notice in each file and include the License file at
3.20 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
3.21 + * particular file as subject to the "Classpath" exception as provided
3.22 + * by Sun in the GPL Version 2 section of the License file that
3.23 + * accompanied this code. If applicable, add the following below the
3.24 + * License Header, with the fields enclosed by brackets [] replaced by
3.25 + * your own identifying information:
3.26 + * "Portions Copyrighted [year] [name of copyright owner]"
3.27 + *
3.28 + * If you wish your version of this file to be governed by only the CDDL
3.29 + * or only the GPL Version 2, indicate your decision by adding
3.30 + * "[Contributor] elects to include this software in this distribution
3.31 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
3.32 + * single choice of license, a recipient has the option to distribute
3.33 + * your version of this file under either the CDDL, the GPL Version 2 or
3.34 + * to extend the choice of license to its licensees as provided above.
3.35 + * However, if you add GPL Version 2 code and therefore, elected the GPL
3.36 + * Version 2 license, then the option applies only if the new code is
3.37 + * made subject to such option by the copyright holder.
3.38 + *
3.39 + * Contributor(s):
3.40 + *
3.41 + * Portions Copyrighted 2009 Sun Microsystems, Inc.
3.42 + */
3.43 +
3.44 +package org.netbeans.performance.scanning;
3.45 +
3.46 +import java.io.File;
3.47 +import java.io.IOException;
3.48 +import java.lang.reflect.InvocationTargetException;
3.49 +import java.util.ArrayList;
3.50 +import java.util.List;
3.51 +import java.util.concurrent.ExecutionException;
3.52 +import java.util.logging.Handler;
3.53 +import java.util.logging.Level;
3.54 +import java.util.logging.LogRecord;
3.55 +import java.util.logging.Logger;
3.56 +import javax.swing.SwingUtilities;
3.57 +import junit.framework.Test;
3.58 +import org.netbeans.api.java.source.ClasspathInfo;
3.59 +import org.netbeans.api.java.source.CompilationController;
3.60 +import org.netbeans.api.java.source.JavaSource;
3.61 +import org.netbeans.api.java.source.Task;
3.62 +import org.netbeans.junit.NbModuleSuite;
3.63 +import org.netbeans.junit.NbPerformanceTest.PerformanceData;
3.64 +import org.netbeans.junit.NbTestCase;
3.65 +import org.netbeans.modules.project.ui.ProjectTab;
3.66 +import org.openide.filesystems.FileObject;
3.67 +import org.openide.filesystems.FileUtil;
3.68 +
3.69 +/**
3.70 + *
3.71 + * @author Pavel Flaška
3.72 + */
3.73 +public class JavaNavigatorPerfTest extends NbTestCase {
3.74 +
3.75 + private final List<PerformanceData> data;
3.76 +
3.77 + public JavaNavigatorPerfTest(String name) {
3.78 + super(name);
3.79 + data = new ArrayList<PerformanceData>();
3.80 + }
3.81 +
3.82 + /**
3.83 + * Set-up the services and project
3.84 + */
3.85 + @Override
3.86 + protected void setUp() throws IOException, InterruptedException {
3.87 + clearWorkDir();
3.88 + System.setProperty("netbeans.user", getWorkDirPath());
3.89 + }
3.90 +
3.91 + public void testEditorPaneSwitch() throws IOException, ExecutionException, InterruptedException, InvocationTargetException {
3.92 + String zipPath = Utilities.projectOpen("http://spbweb.russia.sun.com/~ok153203/jEdit41.zip", "jEdit41.zip");
3.93 + File zipFile = FileUtil.normalizeFile(new File(zipPath));
3.94 + Utilities.unzip(zipFile, getWorkDirPath());
3.95 + final FileObject projectDir = Utilities.openProject("jEdit41", getWorkDir());
3.96 +
3.97 + Logger navigatorUpdater = Logger.getLogger("org.netbeans.modules.java.navigation.ClassMemberPanelUI.perf");
3.98 + navigatorUpdater.setLevel(Level.FINE);
3.99 + navigatorUpdater.addHandler(new NavigatorHandler());
3.100 +
3.101 + JavaSource src = JavaSource.create(ClasspathInfo.create(projectDir));
3.102 +
3.103 + src.runWhenScanFinished(new Task<CompilationController>() {
3.104 +
3.105 + @Override()
3.106 + public void run(CompilationController controller) throws Exception {
3.107 + controller.toPhase(JavaSource.Phase.RESOLVED);
3.108 + }
3.109 + }, false).get();
3.110 + SwingUtilities.invokeAndWait(new Runnable() {
3.111 +
3.112 + public void run() {
3.113 + ProjectTab pt = ProjectTab.findDefault(ProjectTab.ID_LOGICAL);
3.114 + pt.requestActive();
3.115 + FileObject testFile = projectDir.getFileObject("/src/bsh/This.java");
3.116 + pt.selectNode(testFile);
3.117 + }
3.118 + });
3.119 + Thread.sleep(500);
3.120 + SwingUtilities.invokeAndWait(new Runnable() {
3.121 +
3.122 + public void run() {
3.123 + ProjectTab pt = ProjectTab.findDefault(ProjectTab.ID_LOGICAL);
3.124 + pt.requestActive();
3.125 + FileObject testFile = projectDir.getFileObject("/src/org/gjt/sp/jedit/jEdit.java");
3.126 + pt.selectNode(testFile);
3.127 + }
3.128 + });
3.129 + Thread.sleep(5000);
3.130 + SwingUtilities.invokeAndWait(new Runnable() {
3.131 +
3.132 + public void run() {
3.133 + Logger.getAnonymousLogger().log(Level.INFO, "Test finished execution.");
3.134 + }
3.135 + });
3.136 + }
3.137 +
3.138 + @Override
3.139 + protected void tearDown() throws Exception {
3.140 + Logger.getAnonymousLogger().log(Level.INFO, "Processing results.");
3.141 + super.tearDown();
3.142 + for (PerformanceData rec : getPerformanceData()) {
3.143 + Utilities.processUnitTestsResults(JavaNavigatorPerfTest.class.getCanonicalName(), rec);
3.144 + }
3.145 + data.clear();
3.146 + }
3.147 +
3.148 +
3.149 + public static Test suite() throws InterruptedException {
3.150 + return NbModuleSuite.create(NbModuleSuite.emptyConfiguration().
3.151 + addTest(JavaNavigatorPerfTest.class).gui(true));
3.152 + }
3.153 +
3.154 + public PerformanceData[] getPerformanceData() {
3.155 + return data.toArray(new PerformanceData[0]);
3.156 + }
3.157 +
3.158 + private class NavigatorHandler extends Handler {
3.159 +
3.160 + @Override
3.161 + public void publish(LogRecord record) {
3.162 + PerformanceData perfRec = new PerformanceData();
3.163 + perfRec.name = (String) record.getParameters()[0];
3.164 + perfRec.value = (Long) record.getParameters()[1];
3.165 + perfRec.unit = "ms";
3.166 + perfRec.runOrder = 0;
3.167 + perfRec.threshold = 5000;
3.168 + System.err.println(perfRec.name);
3.169 + data.add(perfRec);
3.170 + }
3.171 +
3.172 + @Override
3.173 + public void flush() {
3.174 + }
3.175 +
3.176 + @Override
3.177 + public void close() throws SecurityException {
3.178 + }
3.179 + }
3.180 +}