[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] AspectJ overhead
|
If I refrain from using thisJoinPoint, the overhead is about 10% only.
Please note that I profile with a skeletal aspect, it has not code for logging
or string concatentation.
--
Mohamed
Wes Isberg wrote:
I measured the overhead of my aspect and it adds 120% overhead!!!
Yes, thisJoinPoint is reflective and uses memory.
You might speed up the join point matching by using
staticly-determinable pointcuts -- e.g.,
from
pointcut methodCall(Object o): call(* *(..))
&& target(o) && !javaCode() && !myTrace();
to
pointcut methodCall(): call(!static * *(..))
&& !javaCode() && !myTrace();
Then use thisJoinPoint.getTarget().
But how much time is the logging and how much is the
aspect protocol to log? Put another way, if you disable
logging and String concatenation, does just the aspect
tracing protocol double the time your program takes
to run? That seems like the right measure of the overhead.
Wes
"Mohamed S. Mansour" 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
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users