Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » How to trace the runtime of methods?
How to trace the runtime of methods? [message #66979] Tue, 12 September 2006 09:50 Go to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

Hello Newsgroup,
I want to trace the runtime of methods by using
System.currentTimeMillis(). So first I had a class variable which was
set in the before-advice and was subtracted in the after-advice and then
printed to the output-stream. But then I recognized when there are
nested calls to methods that the runtime of the outer method isn't
correct. Well it is correct because the class variable was set in the
last nested method. So the subtraction results a wrong value. So my idea
was to pass a Calendar-Object from before to after-advice. so that every
method-call has it's own Calendar-Object. But how do I realize this? Is
it possible in some way? Sorry for my bad English - my German is better ;)

greetz
Gilbert Mirenque
Re: How to trace the runtime of methods? [message #66990 is a reply to message #66979] Tue, 12 September 2006 23:54 Go to previous messageGo to next message
Jean Arcand is currently offline Jean Arcand
Messages: 2
Registered: July 2009
Junior Member
Hi Gilbert,

you could try using an around advice instead, something like this :

void around ():yourpointcut() {
long startTime, totalTime;
startTime = System.currentTimeMillis();
proceed();
totalTime = System.currentTimeMillis() - startTime;
}

Jean

> Hello Newsgroup,
> I want to trace the runtime of methods by using
> System.currentTimeMillis(). So first I had a class variable which was
> set in the before-advice and was subtracted in the after-advice and then
> printed to the output-stream. But then I recognized when there are
> nested calls to methods that the runtime of the outer method isn't
> correct. Well it is correct because the class variable was set in the
> last nested method. So the subtraction results a wrong value. So my idea
> was to pass a Calendar-Object from before to after-advice. so that every
> method-call has it's own Calendar-Object. But how do I realize this? Is
> it possible in some way? Sorry for my bad English - my German is better ;)
>
> greetz
> Gilbert Mirenque
Re: How to trace the runtime of methods? [message #66999 is a reply to message #66990] Wed, 13 September 2006 05:07 Go to previous message
Eclipse User
Originally posted by: formatzeh.gmx.de

Jean Arcand wrote:
> Hi Gilbert,
>
> you could try using an around advice instead (..)

Thanks...that's it. I didn't remember that there is the around-advice.

Greetz
G.M.
Re: How to trace the runtime of methods? [message #594733 is a reply to message #66979] Tue, 12 September 2006 23:54 Go to previous message
Jean Arcand is currently offline Jean Arcand
Messages: 2
Registered: July 2009
Junior Member
Hi Gilbert,

you could try using an around advice instead, something like this :

void around ():yourpointcut() {
long startTime, totalTime;
startTime = System.currentTimeMillis();
proceed();
totalTime = System.currentTimeMillis() - startTime;
}

Jean

> Hello Newsgroup,
> I want to trace the runtime of methods by using
> System.currentTimeMillis(). So first I had a class variable which was
> set in the before-advice and was subtracted in the after-advice and then
> printed to the output-stream. But then I recognized when there are
> nested calls to methods that the runtime of the outer method isn't
> correct. Well it is correct because the class variable was set in the
> last nested method. So the subtraction results a wrong value. So my idea
> was to pass a Calendar-Object from before to after-advice. so that every
> method-call has it's own Calendar-Object. But how do I realize this? Is
> it possible in some way? Sorry for my bad English - my German is better ;)
>
> greetz
> Gilbert Mirenque
Re: How to trace the runtime of methods? [message #594745 is a reply to message #66990] Wed, 13 September 2006 05:07 Go to previous message
Eclipse User
Originally posted by: formatzeh.gmx.de

Jean Arcand wrote:
> Hi Gilbert,
>
> you could try using an around advice instead (..)

Thanks...that's it. I didn't remember that there is the around-advice.

Greetz
G.M.
Previous Topic:How to trace the runtime of methods?
Next Topic:RCP Plugins and AspectJ
Goto Forum:
  


Current Time: Mon Apr 21 00:44:34 EDT 2014

Powered by FUDForum. Page generated in 0.03050 seconds