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 (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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With