Possible duplicate:
C ++ High Accuracy Measurement on Windows
I am developing a program that downloads files with ftp, and I am looking for a High-Res timer library to calculate the download speed, now I use C ++ time (NULL), but the results are not accurate.
Is there a simple / easy-to-use, plug-in N-shaped view of the C ++ library for the Windows platform? Something that gives time elapsed seconds after the last call or something like that.
EDIT:
So QueryPerformanceCounter () has been mentioned many times, but going through other threads is what I found out:
You should be warned that it is based on processor frequency. This frequency is unstable when, for example, the power saving mode is turned on. If you want to use this API, make sure that the CPU is at a constant frequency.
Keep in mind that Intel SpeedStep technology can change PerformanceFrequency without notifying your code.
* We also tried to fix the affinity of the thread for our threads to ensure that each thread always received a consistent value from the QueryPerformanceCounter, it worked, but it absolutely killed the performance in the application. *
So, given the situation, is it appropriate to use it? Program effectiveness and timer reliability are very important.
source share