Re: [Dev-C++] Calculating Time in milliseconds
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Rob L. <rob...@nt...> - 2004-11-09 12:26:39
|
sorry but i would like relative time in ms resolution.... i tried using the getTickCount() but this does not seem to be very accurate if i need an ms value <32 ms any other suggestions? also is nanosecond resolution possible? regards Rob ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Rob Lawless" <rob...@nt...> Cc: "DEV-CPP" <dev...@li...> Sent: Monday, November 08, 2004 10:55 PM Subject: Re: [Dev-C++] Calculating Time in milliseconds > Do you want absolute time or relative time in ms resolution? > > For Win32, you can use GetTickCount() that gives number of ms since the > machine booted. It overflows every 49.7 days. > > However, it doesn't tick every ms. For a workstation I think it change > value every 32 ms. > > I haven't bothered to test, but I think the tick interval depends on the > length of time strata used by the windows installation for task switching, > i.e. it will vary between workstation and server installation. > > For better time intervals you can use the performance counters in windows > - they count time in clock cycles of the processor. > > On a unix machine you can use gettimeofday() to get absolute time down > to us resolution, but for this function too, the time is of course not > stepped every microsecond. Note that this function - as compared to the > Win32 GetTickCount() function - takes some time to call, so a program > making large amount of calls will get slowed down. > > /Per W > > On Mon, 8 Nov 2004, Rob Lawless wrote: > > > Hey folks just reading the <ctime> documentation which can only specify a mimimun time in seconds...does anyone know how to calulate a time interval in milliseconds? > > regards > > Rob > |