getUTCtime() increases irregularly

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Apr 4 16:17:40 PDT 2007


david wrote:
> Frits van Bommel schrieb:
>> (Your post header indicates you're running Windows)
>> On Windows, there are (at least) two functions to get the current 
>> time: one returns it as a SYSTEMTIME structure, one as a FILETIME 
>> structure. It looks like std.date uses GetSystemTime; you could try to 
>> see if GetFileTime is more accurate. (no idea why it would be, but you 
>> could try...)
[snip code]
> 
> Thanks for the idea,
> but as you thought the precision is the same,
> d_time currentFileTime()
> {
>     FILETIME ft;
>     GetSystemTimeAsFileTime(&ft);
>     return std.date.FILETIME2d_time(&ft);
> }
> yields the same result as getUTCtime().
> (And for that matter, as a direct GetSystemTime().)

Yeah, it's probably just because your Windows version didn't set 
whatever timer source it uses to >= 1000 ticks/second. Understandable, 
since short timer ticks probably have a negative effect on performance.

I also wouldn't be surprised to find out that different versions of the 
same OS used differently sized timer ticks (getting shorter with more 
recent versions since CPUs keep getting faster and performance penalties 
may drop because of it).
Or for that matter, if the size of a tick can be different on two 
machines running on the same version of the same OS if one machine 
doesn't have a particular (better) timer source in the hardware that the 
other does, or if the OS decides that a faster computer can handle 
shorter timer ticks...


More information about the Digitalmars-d-learn mailing list