限制 CPU 速度进行分析
我正在尝试优化应用程序的几个瓶颈,该应用程序应该在各种 CPU 和架构上运行(其中一些非常接近嵌入式设备)。
然而,由于 CPU 的速度,我的分析器的结果并不真正重要。 有没有什么方法(最好是在 Windows 或 Mac OS X 下)来限制 CPU 的速度以进行分析?
我考虑过使用虚拟机,但还没有找到具有此类功能的虚拟机。
I'm trying to optimize several bottlenecks on an application which is supposed to run on a really wide range of CPUs and architectures (some of them very close to embeded devices).
The results of my profiler, however, aren't really significant because of the speed of my CPU. Is there any way (preferably under Windows or Mac OS X) to limit the speed of my CPU for profiling purposes?
I've thought about using a virtual machine, but haven't found any with such functionality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是一个常见的误解,您需要知道代码的速度有多快才能知道性能问题出在哪里。 这混淆了问题发现和问题衡量。
这是我使用的方法。< /a>
如果程序中有一些浪费的逻辑,那么无论什么CPU运行它都是浪费的。
您需要知道的是它在哪里。 对于测量来说,你不需要知道它有多大;只要知道它有多大,你就可以知道它有多大。 您只需要知道它足够大,需要修复即可。
通常会出现许多不同规模的问题。 您可能会首先找到最大的那些,但无论您以什么顺序修复它们,您修复的每一个都将使找到其余的更容易,因为它们将占据更大的百分比。
It's a common misconception that you need to know how fast your code is to know where your performance problems are. That confuses problem-finding with problem-measurement.
This is the method I use.
If there is some wasteful logic in the program, it will be wasteful no matter what CPU runs it.
What you need to know is where it is. For measurement, you don't need to know how big it is; you only need to know that it is big enough to need to be fixed.
Usually there are a number of problems, of different sizes. You will probably find the biggest ones first, but no matter what order you fix them in, each one you fix will make it easier to find the remaining ones, because they will take a larger percentage.
这运行良好并且支持多核。 http://www.cpukiller.com/
This works well and supports multicore. http://www.cpukiller.com/
恐怕除了开始在您所在的地区寻找旧硬件之外我不知道任何答案。 CPU 并不是唯一可以(通常)影响事物的变量。 L1/L2 缓存大小、内存总线速度、内存速度/延迟、硬盘驱动器速度等都是许多应用中的重要因素。
I'm afraid I don't know any answer other than to start looking around in your area for old hardware. The CPU isn't the only variable that can (usually) affect things. L1/L2 cache size, memory bus speed, memory speed/latency, hard drive speed, etc. are all significant factors in many applications.
最近 Downloadsquad.com 上有一个应用程序。 我不记得它的名字了,但它在处理器和任务管理器方面做了一些有趣的事情。 它可能只是管理什么应用程序在什么CPU上,但也许它会给你这个。 今天下午我会尝试寻找它,如果找到的话就回复。
There was an app on Downloadsquad.com recently. I dont remember the name of it but it did some fun stiff woth processors and task manager. It may have only been to manage what apps are on what cpu but maybe it would give you this. I will try to look for it this afternoon, and respond back if I find it.
许多分析器(例如 oprofile - 但这仅限于 Linux)允许您设置它们收集数据的频率。 查看您的分析器是否支持此功能,如果不支持,请尝试其他支持的分析器。
Many profilers (for example oprofile - but thats linux only) let you set the frequency that they collect data. See if your profiler supports this, and if not try a different one that does.
为什么需要一个明确提供该功能的虚拟机? 只需限制主机操作系统中虚拟机的 CPU 使用率(其中它只是一个常规进程)。 那应该有完全相同的效果。
您可以在 Linux 上使用 cpulimit 来执行此操作; MS Windows 也存在类似的解决方案。
Why do you need a VM that explicitly offers that functionality? Just limit the CPU usage of the VM in the host OS (where it is just a regular process). That should have exactly the same effect.
You can do this e.g. using cpulimit on Linux; similar solutions exist for MS Windows.