Page 1 of 1

Re: [Nagios-devel] Event Profiler Timers?

Posted: Tue Jun 09, 2009 4:35 pm
by Guest
>From: Andreas Ericsson [[email protected]]
>Sent: Tuesday, June 09, 2009 10:55 AM
>To: Nagios Developers List
>Subject: Re: [Nagios-devel] Event Profiler Timers?
>
>>Steven D. Morrey wrote:
>>Hi Everyone,
>>
>>I've been taking a long hard look at my event profiling code and I had a =
thought.
>> We're currently using time(&time_t) to get the function entry and exit t=
imes but is this really precise enough?
>
>It really isn't. I expect most events complete in a lot less than a
>second, yielding a skewed picture of what Nagios spends its time on.
>
>On a side-note, time_t =3D time(NULL) is slightly faster in nearly
>all circumstances since it doesn't require the extra seek+write
>access to the RAM banks.
I never thought about it that way, I'll remember that in the future thanks =
for the heads up.

>> Would it be better (i.e. worth the overhead), to use clock_t
>> =3D clock() to get the entry and exit?
>
>Could be. But then we might as well use gettimeofday() from the start
>so the wrap-around case at least gets exercised a lot instead of
>every 72 minutes.

I don't follow you on that, can you elaborate on what you mean by the wrap-=
around case and it being exercised, because I am not aware of it and theref=
ore have not taken it into consideration.
My primary reasons for wanting to use clock instead of gettimeofday were sp=
eed and precision.

With gettimeofday we are talking about how much calendar time has been spen=
t, whereas with clock we are talking about how many ticks were used by the =
program and then dividing that by clocks_per_second to get a process time.
I believe that clock would be more accurate since it filters out the cost o=
f other processes running on the system.

Another consideration would be the amount of overhead involved.
It appears to me that=20

elapsed_time =3D (double) (end - start) / CLOCKS_PER_SECOND;
total_time +=3D elapsed_time

Would involve significantly less over head than

elapsed_time =3D (end.tv_usec - start.tv_usec) + ((end.tv_sec*1000) -(start=
.tv_sec*1000));
total_time +=3D (double) (elapsed_time / 1000);

Am I wrong or I missing something?
Thanks for the information by the way, it's extremely helpful.

Sincerely,
Steve


NOTICE: This email message is for the sole use of the intended recipient(s=
) and may contain confidential and privileged information. Any unauthorized=
review, use, disclosure or distribution is prohibited. If you are not the =
intended recipient, please contact the sender by reply email and destroy al=
l copies of the original message.







This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]