STM32 Execution Time
In addition to other answers, you can use an oscilloscope if you have one.

At the beginning of your task, set an unused pin (or an LED, etc) high.  Then set it low directly after the task completes.  The o-scope can show you the duration.