Hi, does anyone know of a portable way to measure time that doesn't involve calling to the OS ?
I need to use it in a real-time thread for measuring how long is taking my process to compute some audio. Approximations are ok.
I was thinking on measuring CPU cycles and converting them into time by applying some factor that could be calculated during the application initialization.
There is no way that is both portable and without involving the OS.
If your code runs without an OS, then you can access hardware-specific timers yourself.
If your code runs under an OS, use OS's APIs for this. In modern OS with multitasking and memory protection anything else may be unreliable. For example, the OS may deny you direct access to Intel's TSC.
You could use inline asm. core::arch::arm and core::arch::aarch64 are unstable anyway. If you want to keep it stable, your only option is to write a C function and call it.