[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] AspectJ overhead
|
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
}
//***********************************************//
}