使用周期计数计算吞吐量
是否可以根据应用程序消耗的周期计数(处理器指令周期)来确定处理器上应用程序的吞吐量?如果是,如何计算?
Is it possible to determine the throughput of an application on a processor from the cycle counts (Processor instruction cycles) consumed by the application ? If yes, how to calculate it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果进程完全受 CPU 限制,则可以将处理器速度除以周期数以获得吞吐量。
但实际上,很少有进程完全受 CPU 限制,在这种情况下,您必须考虑其他因素(磁盘速度、内存速度、序列化等)。
If the process is entirely CPU bound, then you divide the processor speed by the number of cycles to get the throughput.
In reality, few processes are entirely CPU bound though, in which case you have to take other factors (disk speed, memory speed, serialization, etc.) into account.
简单:
请注意,您获得的值是一个近似值,有关详细信息,请参阅
clock()< /code> 手册页
。
Simple:
Note that the value you get is an approximation, for more info see the
clock()
man page.某些 CPU 具有内部性能寄存器,使您能够收集各种有趣的统计数据,例如指令周期(有时甚至以每个执行单元为基础)、缓存未命中、缓存/内存读/写数量等等。您可以直接访问这些,但根据您使用的 CPU 和操作系统,很可能存在通过 GUI 为您管理所有详细信息的现有工具。通常,一个好的分析工具将支持性能寄存器,并允许您使用它们收集统计数据。
Some CPUs have internal performance registers which enable you to collect all sorts of interesting statistics, such as instruction cycles (sometimes even on a per execution unit basis), cache misses, # of cache/memory reads/writes, etc. You can access these directly, but depending on what CPU and OS you are using there may well be existing tools which manage all the details for you via a GUI. Often a good profiling tool will have support for performance registers and allow you to collect statistics using them.
如果您使用 TI/Luminary Micro 的 Cortex-M3,则可以使用 TI/Luminary Micro 提供的driverlib。
使用 SysTick 函数,您可以将 SysTickPeriod 设置为 1 个处理器周期:因此中断之间有 1 个处理器时钟。通过计算中断次数,您应该可以“接近估计”函数或功能块花费的时间。
If you use the Cortex-M3 from TI/Luminary Micro, you can make use of the driverlib delivered by TI/Luminary Micro.
Using the SysTick functions you can set the SysTickPeriod to 1 processor cycle: So you have 1 processor clock between interrupts. By counting the number of interrupts you should get a "near enough estimation" on how much time a function or function block take.