Timer function to provide time in nano seconds using C++

前端 未结 16 2327
野趣味
野趣味 2020-11-22 06:02

I wish to calculate the time it took for an API to return a value. The time taken for such an action is in the space of nano seconds. As the API is a C++ class/function, I a

16条回答
  •  深忆病人
    2020-11-22 06:15

    If you need subsecond precision, you need to use system-specific extensions, and will have to check with the documentation for the operating system. POSIX supports up to microseconds with gettimeofday, but nothing more precise since computers didn't have frequencies above 1GHz.

    If you are using Boost, you can check boost::posix_time.

提交回复
热议问题