Hi, I want to know the time spent by a function. I am using vtimestamp for that but with my script i''m getting something like this :- func1 -> func2 -> func2 <- 56624 func1 <- 57899 I want to know the time spent only by func1(). What can I do for that? -- This message posted from opensolaris.org
Ajit Bansode wrote:> Hi, > I want to know the time spent by a function. > I am using vtimestamp for that but with my script i''m getting something like this :- > func1 -> > func2 -> > func2 <- 56624 > func1 <- 57899 > > I want to know the time spent only by func1(). > What can I do for that?something like func1:entry { self->s1 = timestamp; } func2:entry { self->s2 = timestamp; } func2:return { self->d2 = timestamp - self->s2; } func1:return { self->d = (timestamp - self->s1) - self->d2; } you''ll have to put in proper predicates and zero out the temporary variables, but I guess you get the idea. For nested funcN, N > 2, this gets a bit trickier, but we''ll leave that as an exercise to the reader ;-) (I haven''t tested this, btw ... makes things much more fun, right?) HTH Michael -- Michael Schuster Sun Microsystems, Inc. recursion, n: see ''recursion''
Ajit Bansode wrote:> Hi Michael, > Thanks for the help. > Actually there are nested funcNs (don''t know N) in the application. > Pls tell me if there is any other way to do this.I''ve been thinking ... maybe, if the funcNs are truely nested (ie all called from func2 or "below"), you probably wouldn''t have to change what I outlined - it shouldn''t make a difference. If func1 calls other functions (say, func2a, func2b, etc) itself, you''ll have to do the same for them as you did for func2 and modify the final calculation in func1:return accordingly. (the reason I said it''d be trickier was that I started off with a different example, where it would have been ...) Michael> ----- Original Message ---- > From: michael schuster <Michael.Schuster at Sun.COM> > To: Ajit Bansode <ajit.bansode at yahoo.co.in> > Cc: dtrace-discuss at opensolaris.org > Sent: Friday, 31 August, 2007 11:06:52 AM > Subject: Re: [dtrace-discuss] Timespent by a function body > > Ajit Bansode wrote: > > Hi, > > I want to know the time spent by a function. > > I am using vtimestamp for that but with my script i''m getting > something like this :- > > func1 -> > > func2 -> > > func2 <- 56624 > > func1 <- 57899 > > > > I want to know the time spent only by func1(). > > What can I do for that? > > something like > > func1:entry > { > self->s1 = timestamp; > } > > func2:entry > { > self->s2 = timestamp; > } > > func2:return > { > self->d2 = timestamp - self->s2; > } > > func1:return > { > self->d = (timestamp - self->s1) - self->d2; > } > > you''ll have to put in proper predicates and zero out the temporary > variables, but I guess you get the idea. For nested funcN, N > 2, this > gets a bit trickier, but we''ll leave that as an exercise to the reader ;-) > > (I haven''t tested this, btw ... makes things much more fun, right?) > > HTH > Michael > > -- > Michael Schuster Sun Microsystems, Inc. > recursion, n: see ''recursion'' > > > ------------------------------------------------------------------------ > 5, 50, 500, 5000 - Store N number of mails in your inbox. Click here. > <http://in.rd.yahoo.com/tagline_mail_4/*http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/>-- Michael Schuster Recursion, n.: see ''Recursion''
If you''re talking about user code, and statistical data is good enough, you could try the Sun Studio Analyzer. collect <target> <target arguments> analyzer test.1.er will show you a function list with inclusive and exclusive times. Marty Itzkowitz Michael Schuster wrote:>Ajit Bansode wrote: > > >>Hi Michael, >>Thanks for the help. >>Actually there are nested funcNs (don''t know N) in the application. >>Pls tell me if there is any other way to do this. >> >> > >I''ve been thinking ... maybe, if the funcNs are truely nested (ie all >called from func2 or "below"), you probably wouldn''t have to change what I >outlined - it shouldn''t make a difference. If func1 calls other functions >(say, func2a, func2b, etc) itself, you''ll have to do the same for them as >you did for func2 and modify the final calculation in func1:return accordingly. >(the reason I said it''d be trickier was that I started off with a different >example, where it would have been ...) > >Michael > > > >>----- Original Message ---- >>From: michael schuster <Michael.Schuster at Sun.COM> >>To: Ajit Bansode <ajit.bansode at yahoo.co.in> >>Cc: dtrace-discuss at opensolaris.org >>Sent: Friday, 31 August, 2007 11:06:52 AM >>Subject: Re: [dtrace-discuss] Timespent by a function body >> >>Ajit Bansode wrote: >> > Hi, >> > I want to know the time spent by a function. >> > I am using vtimestamp for that but with my script i''m getting >>something like this :- >> > func1 -> >> > func2 -> >> > func2 <- 56624 >> > func1 <- 57899 >> > >> > I want to know the time spent only by func1(). >> > What can I do for that? >> >>something like >> >>func1:entry >>{ >> self->s1 = timestamp; >>} >> >>func2:entry >>{ >> self->s2 = timestamp; >>} >> >>func2:return >>{ >> self->d2 = timestamp - self->s2; >>} >> >>func1:return >>{ >> self->d = (timestamp - self->s1) - self->d2; >>} >> >>you''ll have to put in proper predicates and zero out the temporary >>variables, but I guess you get the idea. For nested funcN, N > 2, this >>gets a bit trickier, but we''ll leave that as an exercise to the reader ;-) >> >>(I haven''t tested this, btw ... makes things much more fun, right?) >> >>HTH >>Michael >> >>-- >>Michael Schuster Sun Microsystems, Inc. >>recursion, n: see ''recursion'' >> >> >>------------------------------------------------------------------------ >>5, 50, 500, 5000 - Store N number of mails in your inbox. Click here. >><http://in.rd.yahoo.com/tagline_mail_4/*http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/> >> >> > > > >