简体   繁体   中英

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. 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.

I've looked into various benchmarking suites such as Nanobench and Google Benchmark, however none have worked. 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. 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. I've noticed this is more frequent in the millisecond scale than the microsecond scale.
  • This is the structure of an example function benchmark:
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. This way you could write timing code once and check the results programmatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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