* Measure time
@ 2002-05-08 8:48 Serguei I. Ivantsov
2002-05-08 12:00 ` Der Herr Hofrat
2002-05-08 12:21 ` Richard B. Johnson
0 siblings, 2 replies; 10+ messages in thread
From: Serguei I. Ivantsov @ 2002-05-08 8:48 UTC (permalink / raw)
To: linux-gcc, linux-kernel
Hello!
Is there any function for high precision time measuring.
time() returns only in second. I need nanoseconds.
--
Regards,
Serguei I. Ivantsov
GSC Game World
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 8:48 Measure time Serguei I. Ivantsov
@ 2002-05-08 12:00 ` Der Herr Hofrat
2002-05-08 15:46 ` Serguei I. Ivantsov
2002-05-08 16:26 ` Calin A. Culianu
2002-05-08 12:21 ` Richard B. Johnson
1 sibling, 2 replies; 10+ messages in thread
From: Der Herr Hofrat @ 2002-05-08 12:00 UTC (permalink / raw)
To: Serguei I. Ivantsov; +Cc: linux-gcc, linux-kernel
> Hello!
>
> Is there any function for high precision time measuring.
> time() returns only in second. I need nanoseconds.
>
you can directly read the TSC but that will not realy give you nanoseconds
resolution as the actual read access even on a PIII/1GHz is going to take
up to a few 100 nanoseconds, and depending on what you want to time
stamp the overall jitter of that code can easaly be in the
range of a microsecond.
There are some hard-realtime patches to the Linux kernel that will
allow time precission of aprox. 1us (the TSC has a precission of 32ns)
but I don't think you can get below that without dedicated hardware.
for RTLinux check at ftp://ftp.rtlinux.org/pub/rtlinux/
hofrat
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 8:48 Measure time Serguei I. Ivantsov
2002-05-08 12:00 ` Der Herr Hofrat
@ 2002-05-08 12:21 ` Richard B. Johnson
1 sibling, 0 replies; 10+ messages in thread
From: Richard B. Johnson @ 2002-05-08 12:21 UTC (permalink / raw)
To: Serguei I. Ivantsov; +Cc: linux-gcc, linux-kernel
On Wed, 8 May 2002, Serguei I. Ivantsov wrote:
> Hello!
>
> Is there any function for high precision time measuring.
> time() returns only in second. I need nanoseconds.
>
> --
> Regards,
> Serguei I. Ivantsov
> GSC Game World
>
gettimeofday() returns seconds/microseconds. If you need nanoseconds,
you can read CPU clock cycles in Intel machines with (assembly) rdtsc
instructions and convert, based upon the CPU clock.
If you really need nanosecond resolution in code that may be
interrupted or preempted at any time, you are in a world of hurt.
I suggest you review the requirement. You may need a TMS320C30 or
similar DSP standing alone.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 12:00 ` Der Herr Hofrat
@ 2002-05-08 15:46 ` Serguei I. Ivantsov
2002-05-08 16:25 ` Nate
` (2 more replies)
2002-05-08 16:26 ` Calin A. Culianu
1 sibling, 3 replies; 10+ messages in thread
From: Serguei I. Ivantsov @ 2002-05-08 15:46 UTC (permalink / raw)
To: Der Herr Hofrat; +Cc: linux-gcc, linux-kernel
Is there any function like GetTickCount() in M$ Win32 that retrieves time in
milliseconds?
--
Regards,
Serguei I. Ivantsov
----- Original Message -----
From: "Der Herr Hofrat" <der.herr@mail.hofr.at>
To: "Serguei I. Ivantsov" <administrator@svitonline.com>
Cc: <linux-gcc@vger.kernel.org>; <linux-kernel@vger.kernel.org>
Sent: Wednesday, May 08, 2002 3:00 PM
Subject: Re: Measure time
> > Hello!
> >
> > Is there any function for high precision time measuring.
> > time() returns only in second. I need nanoseconds.
> >
> you can directly read the TSC but that will not realy give you nanoseconds
> resolution as the actual read access even on a PIII/1GHz is going to take
> up to a few 100 nanoseconds, and depending on what you want to time
> stamp the overall jitter of that code can easaly be in the
> range of a microsecond.
>
> There are some hard-realtime patches to the Linux kernel that will
> allow time precission of aprox. 1us (the TSC has a precission of 32ns)
> but I don't think you can get below that without dedicated hardware.
>
> for RTLinux check at ftp://ftp.rtlinux.org/pub/rtlinux/
>
> hofrat
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 15:46 ` Serguei I. Ivantsov
@ 2002-05-08 16:25 ` Nate
2002-05-08 16:40 ` george anzinger
2002-05-08 16:51 ` Simon Butcher
2 siblings, 0 replies; 10+ messages in thread
From: Nate @ 2002-05-08 16:25 UTC (permalink / raw)
To: Serguei I. Ivantsov; +Cc: linux-gcc
With you can get system time and then use the millisecond member in Win32...
<code>
SYSTEMTIME systm;
GetSystemTime(&systm);
/*
Can access members of the structure
systm.wMilliseconds
systm.wSecond
systm.wMinute
systm.wHour
... and yet more members ...
*/
</code>
~ Nate
----- Original Message -----
From: "Serguei I. Ivantsov" <admin@gsc-game.kiev.ua>
To: "Der Herr Hofrat" <der.herr@mail.hofr.at>
Cc: <linux-gcc@vger.kernel.org>; <linux-kernel@vger.kernel.org>
Sent: Wednesday, May 08, 2002 8:46 AM
Subject: Re: Measure time
> Is there any function like GetTickCount() in M$ Win32 that retrieves time
in
> milliseconds?
>
> --
> Regards,
> Serguei I. Ivantsov
>
> ----- Original Message -----
> From: "Der Herr Hofrat" <der.herr@mail.hofr.at>
> To: "Serguei I. Ivantsov" <administrator@svitonline.com>
> Cc: <linux-gcc@vger.kernel.org>; <linux-kernel@vger.kernel.org>
> Sent: Wednesday, May 08, 2002 3:00 PM
> Subject: Re: Measure time
>
>
> > > Hello!
> > >
> > > Is there any function for high precision time measuring.
> > > time() returns only in second. I need nanoseconds.
> > >
> > you can directly read the TSC but that will not realy give you
nanoseconds
> > resolution as the actual read access even on a PIII/1GHz is going to
take
> > up to a few 100 nanoseconds, and depending on what you want to time
> > stamp the overall jitter of that code can easaly be in the
> > range of a microsecond.
> >
> > There are some hard-realtime patches to the Linux kernel that will
> > allow time precission of aprox. 1us (the TSC has a precission of 32ns)
> > but I don't think you can get below that without dedicated hardware.
> >
> > for RTLinux check at ftp://ftp.rtlinux.org/pub/rtlinux/
> >
> > hofrat
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-gcc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 12:00 ` Der Herr Hofrat
2002-05-08 15:46 ` Serguei I. Ivantsov
@ 2002-05-08 16:26 ` Calin A. Culianu
1 sibling, 0 replies; 10+ messages in thread
From: Calin A. Culianu @ 2002-05-08 16:26 UTC (permalink / raw)
To: Der Herr Hofrat; +Cc: Serguei I. Ivantsov, linux-gcc, linux-kernel
On Wed, 8 May 2002, Der Herr Hofrat wrote:
> > Hello!
> >
> > Is there any function for high precision time measuring.
> > time() returns only in second. I need nanoseconds.
> >
> you can directly read the TSC but that will not realy give you nanoseconds
> resolution as the actual read access even on a PIII/1GHz is going to take
> up to a few 100 nanoseconds, and depending on what you want to time
> stamp the overall jitter of that code can easaly be in the
> range of a microsecond.
>
> There are some hard-realtime patches to the Linux kernel that will
> allow time precission of aprox. 1us (the TSC has a precission of 32ns)
> but I don't think you can get below that without dedicated hardware.
>
> for RTLinux check at ftp://ftp.rtlinux.org/pub/rtlinux/
I recommend RTAI instead. It's more feature-rich, and works with newer
kernels.. the url is http://www.aero.polimi.it/~rtai/, or
http://www.rtai.org.
-Calin
>
> hofrat
> -
> 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/
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 15:46 ` Serguei I. Ivantsov
2002-05-08 16:25 ` Nate
@ 2002-05-08 16:40 ` george anzinger
2002-05-08 16:51 ` Simon Butcher
2 siblings, 0 replies; 10+ messages in thread
From: george anzinger @ 2002-05-08 16:40 UTC (permalink / raw)
To: Serguei I. Ivantsov; +Cc: Der Herr Hofrat, linux-gcc, linux-kernel
"Serguei I. Ivantsov" wrote:
>
> Is there any function like GetTickCount() in M$ Win32 that retrieves time in
> milliseconds?
The kernel provides gettimeofday() which give micro seconds AND is
usually quite accurate. On machines of about 800 MHZ and better you
can, sometimes, even get the same value on back to back readings.
The high-res-timers patch (see sig. below) implements the POSIX clocks
and timers which return values in nanoseconds, but the resolution, due
to jitter and such is still in the range of micro seconds.
If, on the other hand, you are trying to measure execution time of some
task that blocks during that time, you are in a world of hurt. The
kernel allocates 1/HZ chunks of elapsed time to what ever task it finds
running at the 1/HZ tick. There is NO attempt by the kernel to refine
this measurement.
George
>
> --
> Regards,
> Serguei I. Ivantsov
>
> ----- Original Message -----
> From: "Der Herr Hofrat" <der.herr@mail.hofr.at>
> To: "Serguei I. Ivantsov" <administrator@svitonline.com>
> Cc: <linux-gcc@vger.kernel.org>; <linux-kernel@vger.kernel.org>
> Sent: Wednesday, May 08, 2002 3:00 PM
> Subject: Re: Measure time
>
> > > Hello!
> > >
> > > Is there any function for high precision time measuring.
> > > time() returns only in second. I need nanoseconds.
> > >
> > you can directly read the TSC but that will not realy give you nanoseconds
> > resolution as the actual read access even on a PIII/1GHz is going to take
> > up to a few 100 nanoseconds, and depending on what you want to time
> > stamp the overall jitter of that code can easaly be in the
> > range of a microsecond.
> >
> > There are some hard-realtime patches to the Linux kernel that will
> > allow time precission of aprox. 1us (the TSC has a precission of 32ns)
> > but I don't think you can get below that without dedicated hardware.
> >
> > for RTLinux check at ftp://ftp.rtlinux.org/pub/rtlinux/
> >
> > hofrat
>
> -
> 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/
--
George Anzinger george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Measure time
2002-05-08 15:46 ` Serguei I. Ivantsov
2002-05-08 16:25 ` Nate
2002-05-08 16:40 ` george anzinger
@ 2002-05-08 16:51 ` Simon Butcher
2002-05-08 16:58 ` Der Herr Hofrat
2 siblings, 1 reply; 10+ messages in thread
From: Simon Butcher @ 2002-05-08 16:51 UTC (permalink / raw)
To: Serguei I. Ivantsov, Der Herr Hofrat; +Cc: linux-gcc, linux-kernel
Hi,
ftime() will return milliseconds, but it's considered an obsolete function.
You could use gettimeofday() (as Richard Johnson suggested) to get
microseconds and divide them to get milliseconds, although I don't know how
time critical your routines are.
If you're still looking for nanoseconds, I'm told you can use
clock_gettime() but it's still quite unavailable (I've never seen it myself,
yet).. however even if it was available you possibly wouldn't get a very
high resolution from it with current systems..
- Simon
> -----Original Message-----
> From: linux-gcc-owner@vger.kernel.org
> [mailto:linux-gcc-owner@vger.kernel.org]On Behalf Of Serguei I. Ivantsov
> Sent: Thursday, 9 May 2002 01:47
> To: Der Herr Hofrat
> Cc: linux-gcc@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: Measure time
>
>
> Is there any function like GetTickCount() in M$ Win32 that
> retrieves time in
> milliseconds?
>
> --
> Regards,
> Serguei I. Ivantsov
>
> ----- Original Message -----
> From: "Der Herr Hofrat" <der.herr@mail.hofr.at>
> To: "Serguei I. Ivantsov" <administrator@svitonline.com>
> Cc: <linux-gcc@vger.kernel.org>; <linux-kernel@vger.kernel.org>
> Sent: Wednesday, May 08, 2002 3:00 PM
> Subject: Re: Measure time
>
>
> > > Hello!
> > >
> > > Is there any function for high precision time measuring.
> > > time() returns only in second. I need nanoseconds.
> > >
> > you can directly read the TSC but that will not realy give you
> nanoseconds
> > resolution as the actual read access even on a PIII/1GHz is
> going to take
> > up to a few 100 nanoseconds, and depending on what you want to time
> > stamp the overall jitter of that code can easaly be in the
> > range of a microsecond.
> >
> > There are some hard-realtime patches to the Linux kernel that will
> > allow time precission of aprox. 1us (the TSC has a precission of 32ns)
> > but I don't think you can get below that without dedicated hardware.
> >
> > for RTLinux check at ftp://ftp.rtlinux.org/pub/rtlinux/
> >
> > hofrat
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-gcc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 16:51 ` Simon Butcher
@ 2002-05-08 16:58 ` Der Herr Hofrat
2002-05-08 23:22 ` george anzinger
0 siblings, 1 reply; 10+ messages in thread
From: Der Herr Hofrat @ 2002-05-08 16:58 UTC (permalink / raw)
To: Simon Butcher
Cc: Serguei I. Ivantsov, Der Herr Hofrat, linux-gcc, linux-kernel
>
> Hi,
>
> ftime() will return milliseconds, but it's considered an obsolete function.
> You could use gettimeofday() (as Richard Johnson suggested) to get
> microseconds and divide them to get milliseconds, although I don't know how
> time critical your routines are.
>
> If you're still looking for nanoseconds, I'm told you can use
> clock_gettime() but it's still quite unavailable (I've never seen it myself,
> yet).. however even if it was available you possibly wouldn't get a very
> high resolution from it with current systems..
>
clock_gettime() is available in the hard realtime extensions like RTLinux .
The clock resolution is limited to 32ns though - and atleast on X86 I don't
think there is a way to get below that.
hofrat
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Measure time
2002-05-08 16:58 ` Der Herr Hofrat
@ 2002-05-08 23:22 ` george anzinger
0 siblings, 0 replies; 10+ messages in thread
From: george anzinger @ 2002-05-08 23:22 UTC (permalink / raw)
To: Der Herr Hofrat
Cc: Simon Butcher, Serguei I. Ivantsov, linux-gcc, linux-kernel
Der Herr Hofrat wrote:
>
> >
> > Hi,
> >
> > ftime() will return milliseconds, but it's considered an obsolete function.
> > You could use gettimeofday() (as Richard Johnson suggested) to get
> > microseconds and divide them to get milliseconds, although I don't know how
> > time critical your routines are.
> >
> > If you're still looking for nanoseconds, I'm told you can use
> > clock_gettime() but it's still quite unavailable (I've never seen it myself,
> > yet).. however even if it was available you possibly wouldn't get a very
> > high resolution from it with current systems..
> >
> clock_gettime() is available in the hard realtime extensions like RTLinux .
> The clock resolution is limited to 32ns though - and atleast on X86 I don't
> think there is a way to get below that.
The high-res-timers patch provides clock_gettime() with resolution to
the TSC increment. But you need to understand that this is a system
call which can take on the order of 1000 or these units. Add in a
little cach hit/ miss and interrupt randomness and well...
Still, there it is. Check out the web site below.
--
George Anzinger george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2002-05-08 23:22 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-08 8:48 Measure time Serguei I. Ivantsov
2002-05-08 12:00 ` Der Herr Hofrat
2002-05-08 15:46 ` Serguei I. Ivantsov
2002-05-08 16:25 ` Nate
2002-05-08 16:40 ` george anzinger
2002-05-08 16:51 ` Simon Butcher
2002-05-08 16:58 ` Der Herr Hofrat
2002-05-08 23:22 ` george anzinger
2002-05-08 16:26 ` Calin A. Culianu
2002-05-08 12:21 ` Richard B. Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).