I personally use the timestamp counter through an assembly that executes the rdtsc statement. Then I get an unsigned 64-bit integer containing the number of internal clock cycles that have passed since the processor was turned on. The difference between two reads is the number of code cycles required to execute a piece of code between them. Accessing instructions for reading the cache can be implemented in the same way.
Itβs hard for me to understand what conclusions should be drawn from reading cache counters without a time frame for communication. This time interval should not be too long, or a task switch or interrupt can affect the value.
According to Microsoft, an rdtsc device may be inaccurate if the processor has a down-throttle function (to reduce energy consumption) that must be taken into account (or turned off!).
source share