简体   繁体   English

更有效地在微控制器上对 C++ 进行基准测试

[英]Benchmarking C++ on Microcontroller more efficiently

I'm interested in benchmarking the execution speed of various ETL and STL library functions on the NXP LPC 804 microcontroller.我有兴趣在 NXP LPC 804 微控制器上对各种 ETL 和 STL 库函数的执行速度进行基准测试。 Currently, I'm doing so by creating a C++ program for each and every function, and then measuring the results with an oscilloscope, which on another note tends to yield quite variable results.目前,我正在为每个 function 创建一个 C++ 程序,然后用示波器测量结果,另一方面,这往往会产生相当多变的结果。

I've looked into various benchmarking suites such as Nanobench and Google Benchmark, however none have worked.我研究了各种基准测试套件,例如 Nanobench 和 Google Benchmark,但都没有奏效。 Does anyone know of a more efficient solution?有谁知道更有效的解决方案? As this is moreso a methodological inquiry than a programming question per se, I don't have any code to attach.由于这更像是一个方法学探究,而不是编程问题本身,所以我没有任何代码可以附加。

If there is a more suitable Stack Exchange channel for this then I will happily delete this post and repost it there.如果有更合适的 Stack Exchange 频道,那么我会很乐意删除这篇文章并将其重新发布到那里。 Thanks!谢谢!

Edit : To add a bit more detail:编辑:添加更多细节:

  • By 'variable' results, I mean that when I continuously run one function within a while loop, the period duration the oscilloscope gives flickers back and forth between several different frequencies.通过“可变”结果,我的意思是当我在一个 while 循环内连续运行一个 function 时,示波器在几个不同频率之间来回闪烁的周期持续时间。 I've noticed this is more frequent in the millisecond scale than the microsecond scale.我注意到这在毫秒级比微秒级更频繁。
  • This is the structure of an example function benchmark:这是一个示例 function 基准测试的结构:
int main() {
    while (true) {
        // set GPIO pin
        // execute some function
        // clear GPIO pin
    }
    return 0;
}
  • Since this is a formal research evaluation, I was advised to either use a standard benchmarking suite or use an oscilloscope, rather than create benchmarking functions using timers myself, as I was told that microcontroller timers are somewhat imprecise.由于这是一项正式的研究评估,因此建议我使用标准基准测试套件或使用示波器,而不是自己使用计时器创建基准测试功能,因为有人告诉我微控制器计时器有些不精确。

According to the datasheet the LPC804 has a "32-bit general purpose counter/timer", maybe you could configure it to make the measurement.根据数据表,LPC804 有一个“32 位通用计数器/定时器”,也许你可以配置它来进行测量。 This way you could write timing code once and check the results programmatically.这样,您可以编写一次计时代码并以编程方式检查结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM