I'm working on a project that involves recording the time that a certain function takes to run one hundred times. I'm using a solution using the library but I seem to remember that there is a more accurate way that uses the processor's internal timing system for very accurate timing. Is there a better solution, and what's the uncertainty on the result?
Asked
Active
Viewed 48 times
-1
-
What library are you using? Perhaps that library is also using the processor's internal timing system. – Fatih BAKIR Feb 23 '22 at 23:03
-
No way to answer in the general case. You'll need to specify the target OS and probably hardware. – user4581301 Feb 23 '22 at 23:12
-
Warning: `high-resolution_clock` is weakly specified to the point where it can be dangerous to use. [Here's what one of the people most responsible for the chrono library has to say about it](https://stackoverflow.com/questions/37426832/what-are-the-uses-of-stdchronohigh-resolution-clock) – user4581301 Feb 23 '22 at 23:15
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Feb 23 '22 at 23:22
-
Run the thing you want to measure many times and divide the measured time by that number. The more often you run it, the better. – bitmask Feb 23 '22 at 23:51
1 Answers
0
Using the chrono library will be your most accurate option likely. There is no way to know the resolution and accuracy of the clock without knowing exactly your setup, but you can assume it's small enough for all practical uses.

honss
- 18
- 2