Right now, I'm trying to determine a method to measure the time that a particular function will take (something like pthread_create). Now, of course, these types of functions are extremely optimized to take as little time as possible; so little, in fact, that my timer that uses gettimeofday in userspace which measures in microseconds is unable to adequately measure anything.
Normally, if I could mess with the kernel, I'd use something like get_cycles to measure the raw number of cycles as a performance metric. However, I haven't found a way to do this in userspace. Is there a way to use get_cycles (or an equivalent) or some other higher precision timer I could use in userspace to measure extremely fast functions?
Use RDTSC (if you're on x86), or clock_gettime
unsigned long long cycleCount() {
asm ("rdtsc");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With