Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ overhead

This 120 % looks to me awfull...
What type of statements do you use for logging... ?
	System.out.println's or Log4j info statements ?
If your program is multithreaded then it must be than the cause

The presented aspect herebelow is interesting enough in its quality to envisage ot evaluate the usage of StringBuffer's instead of String's when building the String to "printout"...

With Log4j you should use prefereably RollingAppender instead of DailyrollingAppender. You can then ensure that the Appender is buffered with the appropriate buffer size & then File ***never*** gets tooooo big.


Rgds,

Thomas,


mansour@xxxxxxxxxxxxx wrote:
Hi,

I am writing an aspect to trace program execution. Basically, for each method call we want to log the caller, callee and values of formal arguments.

I measured the overhead of my aspect and it adds 120% overhead!!!

By stripping down my aspect, I found out that using thisJoinPoint is the culprit.

Is there an alternative aspect that causes less overhead?
--
Mohamed


aspect TraceAspect {
   pointcut myTrace(): within(TraceAspect) || within(Trace);
   pointcut javaCode(): within(java..*) || call(* java..*(..));

   // a point cut that matches any non-static method call.
   pointcut methodCall(Object o):
          call(* *(..))
          && target(o)
          && !javaCode()
          && !myTrace();

   // a point cut that matches any static method call.
   pointcut staticMethodCall():
          call(static * *(..))
          && !javaCode()
          && !myTrace();

   before (): staticMethodCall() {
      logCaller(thisJoinPoint);
      logCallee(thisJoinPointStaticPart);
   }
   before (Object o): methodCall(o) {
      logCaller(thisJoinPoint);
      logCallee(thisJoinPointStaticPart, o);
   }
   //***********************************************//
   private void logCaller(JoinPoint thisJoinPoint) {
      SourceLocation loc = thisJoinPoint.getSourceLocation();
      // add a log entry

      Object[] args = thisJoinPoint.getArgs();
      for (int i=0; i<args.length; i++) {
         // add a log entry
      }
   }
   private void logCallee(JoinPoint.StaticPart thisJoinPointiStaticPart) {

      Signature sig = thisJoinPointiStaticPart.getSignature();
      // add a log entry
   }
   private void logCallee(JoinPoint.StaticPart thisJoinPointStaticPart,
                          Object target) {
      Signature sig = thisJoinPointStaticPart.getSignature();
      // add a log entry
   }
   //***********************************************//
}

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


--
Thomas SMETS
SCJP2 - Brussels

http://tsmets.lautre.net



Back to the top