简体   繁体   中英

Accurate benchmark under windows

I am writing a program that needs to run a set of executables and find their execution times. My first approach was just to run a process, start a timer and see the difference between the start time and the moment when process returns exit value.

Unfortunately, this program will not run on the dedicated machine so many other processes / threads can greatly change the execution time.

I would like to get time in milliseconds / clocks that actually was given to the process by OS. I hope that windows stores that information somewhere but I cannot find anything useful on the msdn.

Sure one solution is to run the process multiple times and calculate the avrage time, but I wont to avoid that.

Thanks.

The " High-Performance Counter " might be what you're looking for.

I've used QueryPerformanceCounter/QueryPerformanceFrequency for high-resolution timing in stuff like 3D programming where the stock functionality just doesn't cut it.

You could also try the RDTSC x86 instruction.

您可以看一下GetProcessTimes API。

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