Questions tagged [rdtsc]

RDTSC is the x86 read time stamp counter instruction.

RDTSC is the x86 read time stamp counter instruction often used for high resolution timing.

See How to Benchmark Code Execution Times on Intel® IA-32 and IA-64 Instruction Set Architectures.

Get CPU cycle count? has info on various caveats of using it: on modern x86, it measures reference cycles, not actual core clock cycles. (And also shows how to access it from C++.)

The earliest CPUs to support RDTSC had fixed clock frequency, and some OSes found it was more useful as a low-overhead time source time-of-day functions, so CPU vendors eventually changed it to be how it is now: a fixed-frequency nonstop counter.

It can be out-of-sync across different cores. (Some CPUs avoid that for cores in the same physical package.)

137 questions
-1
votes
2 answers

rdtsc timing for a measuring a function

I want to time a function call with rdtsc. So I measured it in two ways as follows. Call it in a loop. Aggregate each rdtsc difference within the loop and divide by number of calls. (Let's say this is N) Call it in a loop. Get the rdtsc difference…
chamibuddhika
  • 1,419
  • 2
  • 20
  • 36
-1
votes
1 answer

How is time calculated?

In order to calculate time we usually use a system call, but what if I wanted to implement it myself, is it possible? Using rdtsc gives me the amount of cpu clocks from the time we turned it on. It is still not possible to calculate the time since…
e271p314
  • 3,841
  • 7
  • 36
  • 61
1 2 3
9
10