Event Profiler Timers?

Steven D. Morrey smorrey at ldschurch.org
Tue Jun 9 19:35:00 CEST 2009


>From: Andreas Ericsson [ae at op5.se]
>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 times 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 = 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
>> = 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 therefore have not taken it into consideration.
My primary reasons for wanting to use clock instead of gettimeofday were speed and precision.

With gettimeofday we are talking about how much calendar time has been spent, 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 of other processes running on the system.

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

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

Would involve significantly less over head than

elapsed_time = (end.tv_usec - start.tv_usec) + ((end.tv_sec*1000) -(start.tv_sec*1000));
total_time += (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 all copies of the original message.



------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects




More information about the Developers mailing list