diff options
author | aclement <aclement> | 2010-01-05 16:48:14 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-01-05 16:48:14 +0000 |
commit | 7339c5da5fb0cdbc403c4fca881fcbcf6b60b994 (patch) | |
tree | d11017fd93807006de81ab4f3536685b66c74424 /weaver5 | |
parent | 4aee36e371e166a9cc653e6daaad877611325211 (diff) | |
download | aspectj-7339c5da5fb0cdbc403c4fca881fcbcf6b60b994.tar.gz aspectj-7339c5da5fb0cdbc403c4fca881fcbcf6b60b994.zip |
parser speed tests
Diffstat (limited to 'weaver5')
-rw-r--r-- | weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java index 47b57fe9a..9b155df3e 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java @@ -141,6 +141,67 @@ public class Java15PointcutExpressionTest extends TestCase { } + private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); + + static { + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); + DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); + } + + public void testPerformanceOfPointcutParsing() { + String expression = "execution(public * rewards.internal.*.*Repository+.*(..))"; + long stime1 = System.currentTimeMillis(); + PointcutParser parser = PointcutParser.getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(DEFAULT_SUPPORTED_PRIMITIVES); + long stime2 = System.currentTimeMillis(); + PointcutExpression pointcutExpression = parser.parsePointcutExpression(expression, null, new PointcutParameter[0]); + long etime = System.currentTimeMillis(); + System.out.println("Time to get a parser "+(stime2-stime1)+"ms"); + System.out.println("Time taken to parse expression is "+(etime-stime2)+"ms"); + } + + + public void testPerformanceOfPointcutParsingWithBean() { + String expression = "execution(public * rewards.internal.*.*Repository+.*(..))"; + PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); + BeanDesignatorHandler beanHandler = new BeanDesignatorHandler(); + parser.registerPointcutDesignatorHandler(beanHandler); + long stime = System.currentTimeMillis(); + PointcutExpression pointcutExpression = parser.parsePointcutExpression(expression, null, new PointcutParameter[0]); + long etime = System.currentTimeMillis(); + System.out.println("Time taken to parse expression is "+(etime-stime)+"ms"); + } + + private class BeanDesignatorHandler implements PointcutDesignatorHandler { + + private String askedToParse; + public boolean simulateDynamicTest = false; + + public String getDesignatorName() { + return "bean"; + } + + /* (non-Javadoc) + * @see org.aspectj.weaver.tools.PointcutDesignatorHandler#parse(java.lang.String) + */ + public ContextBasedMatcher parse(String expression) { + this.askedToParse = expression; + return null; +// return new BeanPointcutExpression(expression,this.simulateDynamicTest); + } + + public String getExpressionLastAskedToParse() { + return this.askedToParse; + } + } + /** * Test matching of pointcuts against expressions. A reflection world is being used on the backend here (not a Bcel one). |