简体   繁体   中英

Difference between GetLocalTime and GetSystemTime?

I am using GetLocalTime in my code to check how much time the particular function is taking for processing.

For this purpose which one is the best choice GetLocalTime or GetSystemTime ?

Are they same ? Which one should be used if I am measuring the performance of the code.

The two functions have the same resolution; the difference is that GetLocalTime returns the system time adjusted for your current timezone (ie your local time rather than UTC).

For measuring the performance of code using either of these functions is probably less than ideal. Instead, I would look at using the performance counter functions as these offer much less overhead and the highest possible resolution.

See the MS knowledge base article for more information: How To Use QueryPerformanceCounter to Time Code (the example code is in VB but the concept applies to C++ as well - basically, use QueryPerformanceCounter to get before and after "ticks", and QueryPerformanceFrequency to convert the ticks to seconds).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM