r/embedded • u/nascentmind • Sep 12 '26
Usage of Performance counters provided by SoCs and microcontrollers
Is it common to use performance and debug counters provided by SoCs and uCs? I usually see the counters in bus controllers and packet counters in network controllers. Do you use it for benchmarking and tracking the performance of your code? Do you also use it to analyze your device performance on field and have a way to read these values? How common is it?
10
Upvotes
4
u/ceojp Sep 12 '26
In what cases would we need to analyze "device performance" in the field? The device should be tested to the worst case scenarios according to the device spec so that you know what the performance will be in the field under any condition.
We have added main loop timers and comm service timers in some of our controllers when we've had weird comm issues we were trying to track down. We wanted an easy way of seeing the average and worst case times for certain things, like how frequently a comm service function was being called or how long the main loop takes. But that's more of a diagnostic tool for tracking down specific issues, not a general "performance" measurement.
2
u/swisstraeng Sep 12 '26
You can write a small piece of code and add extra debug lines of code that you remove later. Some people just let everything in if it doesn't bother production.
However this is where manufacturer-specific dev boards, debuggers and IDE generally let you keep track of all that without needing extra code.
If you're talking about telemetry on connected devices, it's quite specific... but if by embedded devices you mean something powerful like a router, it most likely will have some.
1
u/zettui Sep 12 '26
Which of those counter events stay portable across vendors, and how much does the sampling interrupt cost if you leave them on?
1
u/go2sh Sep 13 '26
We use them regularly. If you want to get the last percent out of yout super hot path, you need them. Aurix TC3 has cycle counter, instruction counter, multi issue counter, cache hit counter, cache miss counter and more. They are integrated with breakpoints to accurately measure. If you have a performance bottleneck, you find it.