Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Time precision better than seconds?? (http://www.chiefdelphi.com/forums/showthread.php?t=73318)

Joohoo 31-01-2009 12:31

Time precision better than seconds??
 
For a while out team has been looking to use a timer. The timer works well, except we need to have a more precise timer than the one that the documentation says is available. Is there a way to make a timer that is more precise (milliseconds/microseconds)?

Eric Finn 31-01-2009 13:20

Re: Time precision better than seconds??
 
If I recall correctly, pretty much everything having to do with time is doubles, so that you have millisecond resolution for the time, but it is measured in seconds. That is, 200 ms would be 0.2 seconds.

Shinigami2057 31-01-2009 13:24

Re: Time precision better than seconds??
 
How accurate is the timing using floating-point precision? IEEE floating point representation isn't always 100% accurate; many times floats won't represent your value exactly as entered (e.g., 0.3 might become 0.2999...) so your times may end up slightly misrepresented internally.

Any reason as to why floating-point numbers were used instead of milli or microseconds?

Uberbots 31-01-2009 13:28

Re: Time precision better than seconds??
 
The real-time timer has a precision down to microseconds i believe, but you wont have any luck searching for anything more fine than that (eg processor ticks)

gvarndell 31-01-2009 20:49

Re: Time precision better than seconds??
 
Quote:

Originally Posted by Joohoo (Post 811601)
For a while out team has been looking to use a timer. The timer works well, except we need to have a more precise timer than the one that the documentation says is available. Is there a way to make a timer that is more precise (milliseconds/microseconds)?

You can call vxTimeBaseGet(), which is a function provided in vxLib.

IMPORT void vxTimeBaseGet (UINT32 * pTbu, UINT32 * pTbl);

This function reads the 64-bit PPC timebase, storing the upper 32 bits at pTbu and the lower 32 bits at pTbl.

The least significant bit should be worth 1/132,000,000 of a second.
It would pay to do a little experimentation with it though, to see if that number is right -- it may actually be 1/133,000,000 seconds.
In any event, it's a very high resolution 64-bit counter.
Precise enough for ya?


All times are GMT -5. The time now is 02:42.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi