Benchmarking C++ on Microcontroller more efficiently

Viewed 174

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

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.

Related