arm裸机系统上的CPU使用率测量

CPU usage measurment on arm bare metal system(arm裸机系统上的CPU使用率测量)

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

问题描述

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

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使用率测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:arm裸机系统上的CPU使用率测量

基础教程推荐