Skip to main content

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

> 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.

Your logCaller method is asking for a lot of work to be done.

   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
       }
    }

AspectJ has to allocate a thisJoinPoint object, and it has to marshall
all the args into the Object[] array.  In general, thisJoinPoint requires
AspectJ to allocate structure at each applicable join point, whereas
thisJoinPointStaticPart does not.

You might try just doing what you can do with thisJoinPointStaticPart
and seeing what the overhead is for that.  Then consider whether logging
all the arguments is is worth it to you.
    



Back to the top