Re: How do we profile our code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2006-02-22 at 18:00 +0530, Manav Kataria wrote:
> Hi Hayim,
> > Is this a user-space application or kernel module, you want to profile?
> I want to profile a user-space application.
> 
> > I also use clock():
> Where is clock() defined?

# man clock

> I just wanted to confirm this:
> Using gettimeofday() will never give me a correct result because:
> It is a user space app. which the scheduler can kick out anytime. Right? 
> Anything else ?

You will have this issue with any method you choose - you can only hope
to minimize the effects.

> Secondly, the resolution that i get thru gettimeofday() after conversion 
> can be upto microseconds. But I fear that is fake ?
> A resolution upto millisecond is correct? This has something to do with 
> the sys clock / timing issues I read somewhere.

What do you mean by "fake"?  If the code that you're timing takes a
relatively long time to run, then small variations caused by
gettimeofday() will not affect your results by too much.  If you are
timing short segments, it may be useful to run the segment in a loop,
and divide the time by the number of iterations (of course you want to
ensure that each iteration will approximately the same amount of work -
for example, if you were reading data, the first iteration might be
uncached, and the rest would be cached).  It would also help if you used
a faster timing instruction - I usually just use some assembly to read
the TSC register before and after the code section, giving me the number
of cycles.

Avishay Traeger
http://www.fsl.cs.sunysb.edu/~avishay/


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux