Sergey Kostrov wrote:
>>In nanoseconds I do measurements for very small and critical sections of codes using rdtsc instruction.
Actually in clock cycles and it is very easy to convert a value to nanoseconds.
Just a note for other readers, I think there is no way to measure CPU cycles on today's IA other than relying on the PMU. In fact, this is not the guilty of Intel Turbo Boost or so, but rather one possible definition carried forward from ages where CPU cycles and clock cycles were the same. In particular, the RDTSC instruction does not measure CPU cycles but rather measures clock cycles (as you mentioned!).
For more complete information about compiler optimizations, see our Optimization Notice.