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-08 22:55:25
|
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 |