diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-04-25 15:11:23 +0200 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-04-26 09:58:56 +0200 |
commit | c398a2105d7bf8153c2ef13dea372bcfa6c33a48 (patch) | |
tree | 99750e0478154803921878da32be9fe14ddf3e9b /weaver/src/test | |
parent | 7d19004b111542c878120636da406a6c47f686aa (diff) | |
download | aspectj-c398a2105d7bf8153c2ef13dea372bcfa6c33a48.tar.gz aspectj-c398a2105d7bf8153c2ef13dea372bcfa6c33a48.zip |
Add ClasspathManagerTestCase::testUnfoundClassPerformance
Performance regression test for #306, failing before the enhancement and
passing afterward.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'weaver/src/test')
-rw-r--r-- | weaver/src/test/java/org/aspectj/weaver/bcel/ClasspathManagerTestCase.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/ClasspathManagerTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/ClasspathManagerTestCase.java index 1c8d7a918..1dcce6842 100644 --- a/weaver/src/test/java/org/aspectj/weaver/bcel/ClasspathManagerTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/bcel/ClasspathManagerTestCase.java @@ -23,6 +23,7 @@ import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessage.Kind; import org.aspectj.bridge.IMessageHandler; import org.aspectj.util.LangUtil; +import org.aspectj.weaver.TypeFactory; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.bcel.ClassPathManager.ClassFile; @@ -76,7 +77,33 @@ public class ClasspathManagerTestCase extends TestCase { } public void testInstructions() { - System.out.println("This test is really only for standalone usage as it need executing on multiple JDK levels"); + System.out.println( + "This test is mostly for stand-alone usage (rename 'xtest*' to 'test*'), " + + "as it needs execution on multiple JDK levels" + ); + } + + /** + * See <a href="https://github.com/eclipse-aspectj/aspectj/issues/306">GitHub issue 306</a> + */ + public void testUnfoundClassPerformance() { + final int ROUNDS = 10_000; + final int MAX_TIME = 500; + + List<String> classPath = Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator)); + //System.out.println(classPath); + ClassPathManager classPathManager = new ClassPathManager(classPath, null); + UnresolvedType unresolvedType = TypeFactory.createTypeFromSignature("Ljava/lang/String;"); + + long startTime = System.currentTimeMillis(); + for (int i = 0; i < ROUNDS; i++) + classPathManager.find(unresolvedType); + long duration = System.currentTimeMillis() - startTime; + + assertTrue( + String.format("Duration for %d rounds should be < %d ms, but was %d ms", ROUNDS, MAX_TIME, duration), + duration < MAX_TIME + ); } public void xtestSanity18accessing18RTJAR() throws IOException { |