[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Question about profiling
|
To simplify Mohamed's suggestion for the multithreaded case, you could use a
subclass of java.lang.ThreadLocal whose implementation of initialValue()
returns an instance of Stack() and use those in exactly the same way as the
single threaded case.
Eric
-----Original Message-----
From: mansour@xxxxxxxxxxxxx [mailto:mansour@xxxxxxxxxxxxx]
Sent: Tuesday, June 17, 2003 7:48 AM
To: aspectj-users@xxxxxxxxxxx
Subject: 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
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users