Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Question about profiling

I tried something similar before. Here is what I did:
Add a Stack object to your aspect. At each function entry, push the timestamp to the stack. At function exit generate a time stamp for exit and pop the enter timestamp from the stack, This should work for single threaded applications. For multithreaded applications you should use a map. The key of the map is the thread ID and the valu is the stack mentioned above.

--
Mohamed

> 
> Hello,
> 
> 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)?
> 
> Sorry if this is a FAQ, but I've found nothing that would explain how to 
> solve this.
> 
> Thanks in advance,
> 
> Johann Uhrmann
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top