[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Question about profiling
|
Johann Uhrmann wrote:
> I am quite new to AspectJ and I would like to write a profiling aspect
> that hooks into all method calls of a package and its subpackages.
>
> Before every call the current system time should be saved and after the
> call the method execution time should be determined.
>
> My problem is that I do not know where to store the variable for the
> start time stamp. Storing it in the aspect does not work as it seems to
> be global and is therefore destroyed by calls within the method.
>
> Storing it in java.lang.Object does not work either as the weaver does
> not have access to that class.
>
> Is there a way to store a variable in an aspect in a way that it is
> unique to a method call (or at least to the object calling/being called)?
I believe this is best solved with around advice, as shown below:
Object around(): profilePoints() {
long start = System.currentTimeMillis();
Object ret = proceed();
long end = System.currentTimeMillis();
noteTime(thisJoinPoint.getSignature().getName(), end-start);
return ret;
}
-Jim