Re: [Dev-C++] Calculating Time in milliseconds
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2004-11-09 14:44:16
|
As I said, the performance counters (which are extra registers inside Pentium-class processors) can keep track of the individual clock cycles of the processor, i.e. better than ns resolution. /Per W On Tue, 9 Nov 2004, Rob Lawless wrote: > 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 > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |