Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 655
SyntaxError Avatar asked Oct 04 '22 15:10

SyntaxError


1 Answers

The two functions have the same resolution; the difference is that GetLocalTime returns the system time adjusted for your current timezone (i.e. 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).

like image 83
Jonathan Potter Avatar answered Oct 12 '22 10:10

Jonathan Potter