I tried to use the DWT CYCNT for F103 but I do not succeed to write properly the DWT CTRL register. I think it locked by default (probably because I used STLink) so it required to be unlocked.
I found this nice example and think I'm in this case:
https://github.com/PetteriAimonen/STM32 ... mple.c#L35
but I did not checked.