Rdtsc() based elapsed time?

I want a cheap "elapsed time" implementation using rdtsc (on x86_64 - whatever is equivalent instruction on other architectures) to calculate the rdtsc delta and translate that to actual elapsed time (nano seconds etc..). Is there a lib/crate available somewhere?

Rgds,
Gopa.

If you want to go low-level, there is a crate named x86, which holds a bunch of assembly intrinsics. rdtsc is present, too.

upd: looks like it is a reexport of core function - for 32-bit or for 64-bit, depending on the target architecture.

1 Like

Yeah, I am using that for _rdtsc(), but I was hoping someone has a nice api somewhere :slight_smile: which gets me the tsc frequency on the cpu so that I can convert tsc to time