I second TDK's benchmarking advice - measuring duration over many iterations and calculating the average time per iteration is more precise than trying to measure a single iteration. That said, it depends on how long a single iteration takes. What you're really trying to do is to ensure that the measurement overhead is negligible compared to the processing time, so that your measurement isn't skewed.
An alternative way to measure time deltas with reasonable accuracy is to use the SWV trace capability. Essentially, you use the cycle timestamp that's logged when calling ITM_SendChar to capture timing information. It's not as accurate (if you look at ITM_SendChar implementation, it does more more there than a simple register access), but as long as your measuring something sufficiently long, the relative error can be made negligible.
See Youtube-STM32CubeIDE Advanced Debug Features: Part 3 for a walk-through of how to do this.
This entire playlist is worth your time if you're relatively new to STM32/Cube/Embedded.
Good luck with your project. Remember that student projects are as much about learning from failure as they are about doing something actually useful. You can get a lot of mileage out of doing a solid analysis of why things you tried didn't pan out - so consider taking some chances along the way (The wisdom of this advice strongly depends on your institutional context, of course, but I hope what I'm saying is true wherever you are).
"- If someone's post helped resolve your issue, please thank them by clicking ""Accept as Solution"".- Please post an update with details once you've solved your issue. Your experience may help others."