Re: timing an application

From: Chris Friesen (cfriesen@nortelnetworks.com)
Date: Tue Jan 14 2003 - 15:07:01 EST


Maciej Soltysiak wrote:
> Hi,
>
> being inspired by some book about optimizing c++ code i decided to do
> timing of functions i wrote. I am using gettimeofday to set
> two timeval structs and calculate the time between them.
> But the results depend heavily on the load, also i reckon that this
> is an innacurate timing.
>
> Any ideas on timing a function, or a block of code? Maybe some kernel
> timers or something.

gettimeofday() is accurate. However, your task may be interrupted by
other tasks, interrupts, etc.

Your best bet may be to do many iterations of the routine in question and then
do some statistical analysis of the results.

Chris

-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:51 EST