arm裸机系统CPU使用率测量 [英] CPU usage measurment on arm bare metal system

查看:28
本文介绍了arm裸机系统CPU使用率测量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 ARM cortex M4 评估板,它是一个 裸机 应用程序,上面没有运行任何操作系统.

I am working on a ARM cortex M4 evaluation board, its a bare metal application without any operating system running on it.

现在我想测量给定进程/算法的 CPU 使用情况,最好的方法是什么?

Now I want to measure CPU usage of a given process/algorithm , what would be the best way to do so?

我是否应该实现一个操作系统来衡量具有此类需求的功能的 CPU 使用率?

Should i implement an operating system to measure the CPU usage that have the functionality for such demand?

推荐答案

这个问题几乎可以自圆其说.当您的裸机应用程序不在该流程/算法中时,它在做什么?测量一个或另一个或两者.如果您的裸机应用程序没有完全消耗此算法中的 cpu,那么您已经拥有一个操作系统,可以管理此应用程序/功能的时间.您可以在相对于计时器的循环中使用来自简单计数器的多种方法,以查看当算法获得时间片与否时每个循环有多少计数.您可以简单地对算法本身等进行计时.

The question almost answers itself. What is your bare metal application doing when it is not in that process/algorithm? Measure one or the other or both. If you have a bare metal application that is not completely consuming the cpu in this algorithm, then you already have an operating system to the extent that you are managing this application/function's time. You can use a number of methods from a simple counter in a loop relative to a timer to see how many counts per loop when the algorithm is getting time slices vs not. You can simply time the algorithm itself, etc.

我假设当您说 CPU 时,您的意思是整个系统,因为您的性能在很大程度上取决于您的代码及其正在通信的内容.如果根据时钟频率从 cortex-m4 上的闪存运行,您可能正在燃烧处理器周期,只是在等待指令或数据(并且很容易获得算法的处理器性能的错误概念,当它不是算法燃烧时钟时).缓存屏蔽/操纵该性能,如果您不小心并意识到它们在做什么,很容易对性能产生重大影响.作为一个 C++ 问题,您的编译器在性能和代码方面发挥着重要作用,当然,可以很容易地使代码运行速度提高或降低几倍,而对命令行或代码进行最少的更改.

I assume when you say CPU you mean the whole system as your performance is heavily dependent both on your code and what it is talking to. If running from flash on a cortex-m4 depending on the clock rate you may be burning processor cycles just waiting for instructions or data (and can very easily get the wrong notion of processor performance for an algorithm when it isnt the algorithm burning clocks). The caches mask/manipulate that performance and can easily greatly affect the performance if you are not careful and aware of what they are doing. Being a C++ question your compiler plays a large role in performance as well as your code of course, can very easily make the code run several times faster or slower with minimal changes to the command line or code.

如果算法是 isr 的一部分,则处理器进入睡眠状态,否则,您可以使用 gpio 引脚和示波器技术来了解运行与睡眠比率.

If the algorithm is part of an isr then the processor goes to sleep otherwise, you can use the gpio pin and scope techinique to get a feel for the running vs sleeping ratio.

这篇关于arm裸机系统CPU使用率测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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