Should GetLocalTime () "skip back"?

I know I QueryPerformanceCounter

can return values ​​that are not monotonic / intermittent (i.e. time can appear backwards) due to sampling from unsynchronized clocks distributed across multicore or multiprocessor architectures.

I would have thought I had GetLocalTime()

avoided these problems, although I cannot find anything definite to say about it. When I created this function:

int GetTimeAsMillisecondsSinceMidnight()
{
    SYSTEMTIME theTime;
    GetLocalTime( &theTime );
    return 3600000*theTime.wHour + 60000*theTime.wMinute
        + 1000*theTime.wSecond + theTime.wMilliseconds;
}

      

... I was surprised to create events at 20-30 per second, timestamp using the return value from this function, and find out that sometimes the timestamp "bounced back" by as much as 4 seconds on a reasonably updated 64-bit Windows 8 system running on a Core i7 processor.

What is the likely cause of this "jump back" in time? If GetLocalTime()

is the culprit, are there any alternatives that have similar resolution / precision but avoid the timing gap issues?

+3
c ++ windows


source to share


No one has answered this question yet

See similar questions:

6
Temporary API permission for GetLocalTime ()

or similar:

2299
When should static_cast, dynamic_cast, const_cast, and reinterpret_cast be used?
1699
What is a smart pointer and when should I use it?
1483
Why should I use a pointer and not the object itself?
824
Why do C ++ programmers minimize the use of "new"?
638
When should you use class vs struct in C ++?
632
What should main () return in C and C ++?
567
What is std :: move (), and when should it be used?
2
Uniform control of program execution speed [Windows C ++]
1
Accurate time delta for moderate time intervals: GetTickCount64 vs QueryPerformanceCounter
1
Why does Python time.time () return the wrong result?



All Articles
Loading...
X
Show
Funny
Dev
Pics