用于精确测试程序/算法性能的工具 [英] Tool for testing exactly the performance of program / algorithm

查看:117
本文介绍了用于精确测试程序/算法性能的工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于今天的现代计算机,对于编写大多数小程序的新手程序员来说,无法确定哪个程序/算法的性能更好。是否有一个工具可以测量Windows中的特定程序的CPU负载和内存负载以及其他性能指标(.exe文件,应用程序)?由于我的小程序相对于Windows自己的进程或我的任何计算机程序都没有消耗太多功率,我不能使用任务管理器。



本质上,在短期内,这仅对我的算法有用,因为我通常会编写一些有点不寻常的算法,并且可能具有与该类型的标准算法不同的性能(时间和内存)。从长远来看,这样的程序非常有用,它可以准确指定程序使用的RAM字节数,CPU运行的命令数,花费的时间等等。



我尝试过:



谷歌搜索和搜索这些论坛。

With today's modern computers, for novice programmers who write mostly small programs, it's not possible to tell which program / algorithm performs better. Is there a tool that measures CPU load and memory load and other performance metrics of a particular program in Windows (an .exe file, an application)? Since my small programs don't eat up much power relative to Windows' own processes or any of my computer's programs, I can't use Task Manager for this.

Essentially, in the short term, this will be useful only for my algorithms as I typically write ones that are a bit unusual and may have different performance (time and memory) than the standard algorithm of that type. In the long term, a program like this would be immensely useful, one that specifies exactly how many bytes of RAM were used by the program, how many commands the CPU ran, how much time it took, etc.

What I have tried:

Googling and searching these forums.

推荐答案

程序的简单计时就足够了。开始时,将时间保存在变量中,运行程序,最后读取时间,差异就是运行时间。

如果程序太快,请将其放入循环并运行它需要时间。



A simple timing of the program can be enough. At beginning, save the time in a variable, run the program, read time at the end, the difference is your runtime.
If program is too fast, put it in a loop and run it as many times as needed.

StartTime = Timer
For RunCount = 1 to 10
    ' My Program Here
Next
EndTime = Timer
RunTime = EndTime - StartTime



如果您需要更多详细信息,探查器可以提供帮助。


if you need more details, a profiler can help.


这篇关于用于精确测试程序/算法性能的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆