I sent this directly to Ian (damn reply vs. reply all) , its probably
usefull for everyone to see as well.

----- Original Message -----
From: "Shaya Potter" <[EMAIL PROTECTED]>
To: "Ian Patrick Thomas" <[EMAIL PROTECTED]>
Sent: Wednesday, October 24, 2001 7:46 PM
Subject: Re: More accurate time feedback


> look at the <asm/msr.h>
>
> you might be able to use the CPU counter registers.
>
> if you want info on how to use them, look at
>
> something like
>
> inline void getcycles ( long long int * cycles)
> {
> unsigned long low;
> long high; rdtsc(low,high);
> *cycles = high;
> *cycles <<= 32;
> *cycles |= low;
> }
>
> should return the amount of CPU cycles gone by.
>
> 1cycle = 1000/(mhz of your machine) nano seconds
>
> shaya
>
>
> On Wed, 2001-10-24 at 19:29, Ian Patrick Thomas wrote:
> > Is there a way to get a more accurate time value, preferably to a
> > nanosecond, using the system clock? I need to write a program that needs
to
> > output the time it takes various sorting algprithms to sort various
numbers
> > of integers. For smaller numbers of integers on algorithms like
quicksort,
> > and mergesort, I am getting 0 for the runtime. I need a function that I
can
> > call before the sort begins and after it ends that would return a time
> > value, preferably to the nanosecond. Is there a library out there that
can
> > do this or is the answer right on my machine and I just haven't found it
> > yet?
> >
> > Ian Thomas
> > --
> > FreeSoftware Developer
> > and user of Debian GNU/Linux
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> >
> > --
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]
>
>


Reply via email to