简体   繁体   English

Windows下的准确基准

[英]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. 我想获得OS实际分配给进程的时间(以毫秒/时钟为单位)。 I hope that windows stores that information somewhere but I cannot find anything useful on the msdn. 我希望Windows将这些信息存储在某个地方,但我找不到在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. 我已经使用QueryPerformanceCounter / QueryPerformanceFrequency在诸如3D编程之类的东西中进行高分辨率定时,而其中的库存功能只是不能削减它。

You could also try the RDTSC x86 instruction. 您也可以尝试RDTSC x86指令。

您可以看一下GetProcessTimes API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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