Hey Sam,
I understand that you are facing an issue where "profile viewer" is showing good exceution time for the generated code but not on your target.
You can use the tic and toc function, tic works with the toc function to measure elapsed time. The tic function records the current time, and the toc function uses the recorded value to calculate the elapsed time.
Also you can try the following methods to optimize your code-
- Static Code Metrics Report: Use this for measuring the memory allocation quantitatively. This is only available with the Embedded Coder.
- Model Advisor: Use the Code Generation Efficiency checks to identify optimization opportunities.
- Code Generation Advisor: Set the optimization objectives.
I hope this helps!