Bo, To get the best performance there is a pattern you should follow which is documented in Chapter 11 of "eclipse AspectJ". Firstly you should use an if() pointcut (which you have) which returns false when logging is disabled. Secondly if you are using thisJoinPoint to capture method parameters it should only be used in before advice when logging method entry; use thisJoinPointStatic part in after advice for method exit. Thirdly use -XlazyTjp which is now the default in AspectJ 1.5.3.
Micro-benchmarks have their place but are not the best way to assess the overall impact on the application. I would suggest using a benchmark that exercises your application as a whole. Also you should compare apples with apples i.e. an aspect with its hand-coded equivalent. If you don't want to do that once you have an efficient aspect pick an overhead you are comfortable with instead e.g. 5%. Then adjust the scope of you aspect i.e. which methods/classes to achieve it. Matthew Webster AOSD Project Java Technology Centre, MP146 IBM Hursley Park, Winchester, SO21 2JN, England Telephone: +44 196 2816139 (external) 246139 (internal) Email: Matthew Webster/UK/IBM @ IBMGB, [EMAIL PROTECTED] http://w3.hursley.ibm.com/~websterm/ Bo Li <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 14/01/2007 22:53 Please respond to [email protected] To [email protected] cc Subject [aspectj-users] AspectJ Performance Hello All We are currently evaluating the possibility of using AspectJ for the debug logging component of our project. One of the major requirements is that there should be minimal performance impact when the debug logging component is turned off. I was doing some performance testing with AspectJ and it seems like there is a 35% - 50% decrease in performance after the aspects are woven into our classes. My benchmark pretty much just measures the number of calls to a method that increments a integer 1000 times. Without the aspects, we would see around 470 calls/ms. With an advice that has an entry and exit pointcut just for that method woven in, we see around 300 calls/ms. Each pointcut only contains an if statement that always evaluate to false to simulate logging turned off. Digging in to the woven code, I noticed ajc inserted the following code right after the method signature: org.aspectj.lang.JoinPoint joinpoint = Factory.makeJP(ajc$tjp_0, this, this); This seems to be an expensive operation, especially for every method entry. Are there any ways to speed up this case so that AspectJ adds as little overhead as possible when the pointcut doesn't do anything? It would be ideal if there was a way to control executing expensive operations like the one above so that they are done only when necessary. Thank you for your help! Bo Li - [EMAIL PROTECTED] Software Engineer - Directory Server Sun Microsystems Inc. _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
