- Joined
- 7/8/15
- Messages
- 1,004
- Points
- 343
Can anyone recommend a way to count CPU cycles? Should we be using some facilities in std::chrono instead of the TSC register?
I've read about the TSC register that can be read using the RDTSC instruction. However, I see on Wikipedia and Stackoverflow that RDTSC has a lot of flaws on modern CPUs. For example this quote:
"The Time Stamp Counter was once an excellent high-resolution, low-overhead way for a program to get CPU timing information. With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and hibernating operating systems, the TSC cannot be relied upon to provide accurate results"
I've read about the TSC register that can be read using the RDTSC instruction. However, I see on Wikipedia and Stackoverflow that RDTSC has a lot of flaws on modern CPUs. For example this quote:
"The Time Stamp Counter was once an excellent high-resolution, low-overhead way for a program to get CPU timing information. With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and hibernating operating systems, the TSC cannot be relied upon to provide accurate results"