Home > OS >  What is the most accurate way to measure the time to perform a function, and what is its accuracy?
What is the most accurate way to measure the time to perform a function, and what is its accuracy?

Time:02-24

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?

CodePudding user response:

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.

  •  Tags:  
  • c
  • Related