diff options
author | Terry Parker | 2013-11-06 16:22:25 +0000 |
---|---|---|
committer | Jayaprakash Arthanareeswaran | 2014-04-05 08:07:58 +0000 |
commit | 051572f99b6a73010e844cbf76e196d479c1689d (patch) | |
tree | a3556ad10035c50a5c98f9c91c8e1e4150e07abb /org.eclipse.jdt.core.tests.performance/src | |
parent | 3fd9ba7770cab33e59f381d90c14d9b1a2469d1c (diff) | |
download | eclipse.jdt.core-051572f99b6a73010e844cbf76e196d479c1689d.tar.gz eclipse.jdt.core-051572f99b6a73010e844cbf76e196d479c1689d.tar.xz eclipse.jdt.core-051572f99b6a73010e844cbf76e196d479c1689d.zip |
Fixed bug 421165: Low hit rates in JavaModel caches
Change-Id: Ib1920cfdc87fcb57f2e36d61b4bd382cc771297b
Signed-off-by: Terry Parker <tparker@google.com>
Diffstat (limited to 'org.eclipse.jdt.core.tests.performance/src')
-rw-r--r-- | org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java index 2cd10aa25c..259c2d8a37 100644 --- a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java +++ b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Thirumala Reddy Mutchukota <thirumala@google.com> - Contribution to bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=411423 + * Terry Parker <tparker@google.com> - [performance] Low hit rates in JavaModel caches - https://bugs.eclipse.org/421165 *******************************************************************************/ package org.eclipse.jdt.core.tests.performance; @@ -1501,6 +1502,66 @@ public void testResolveClasspath() throws Exception { } } +/* + * Overriding getExternalPath() to be on a non-local disk (e.g., NFS) shows the advantages + * of caching file existence checks in the testJavaModelManagerExternalFilesCache() test. + */ +protected String getExternalPath() { + // NOTE: Do something similar to this commented-out code to set up the tests to + // use a non-local file system. + // return "/home/" + System.getProperty("user.name") + "/performance_test/"; + return super.getExternalPath(); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=421165 +public void testGetAllPackageFragmentRoots() throws Exception { + int jarCount = 100; + IClasspathEntry[] oldClasspath = BIG_PROJECT.getRawClasspath(); + try { + IClasspathEntry[] classpath = new IClasspathEntry[jarCount]; + for (int index = 0; index < jarCount; index++) { + String filePath = getExternalResourcePath("lib"+ index +".jar"); + org.eclipse.jdt.core.tests.util.Util.createJar(new String[0], + new String[] { + "META-INF/MANIFEST.MF", + "Manifest-Version: 1.0\n", + }, + filePath, + JavaCore.VERSION_1_4); + classpath[index] = JavaCore.newLibraryEntry(new Path(filePath), null, null); + } + BIG_PROJECT.setRawClasspath(classpath, null); + IFile file = (IFile) WORKING_COPY.getResource(); + + // warm up + int max = 20; + int warmup = WARMUP_COUNT / 10; + for (int i = 0; i < warmup; i++) { + for (int j = 0; j < max; j++) { + file.touch(null/*no progress*/); + BIG_PROJECT.getAllPackageFragmentRoots(); + } + } + + // measure performance + for (int i = 0; i < MEASURES_COUNT; i++) { + runGc(); + startMeasuring(); + for (int j = 0; j < max; j++) { + file.touch(null/*no progress*/); + BIG_PROJECT.getAllPackageFragmentRoots(); + } + stopMeasuring(); + } + + commitMeasurements(); + assertPerformance(); + + } finally { + BIG_PROJECT.setRawClasspath(oldClasspath, null); + } +} + protected void resetCounters() { // do nothing } |