Get time stamp via Boost.Chrono in resolution of n

2019-08-20 17:49发布

问题:

Does boost chrono provides time stamp with nanoseconds resolution?? If yes how to get the time stamp?

回答1:

Nanoseconds resolution ? On which hardware do you want to run your program ? On my PC, my performance counter has a frequency of approx. 4 Mhz, so a tick last 250 ns.

As answered here, boost chrono can give you the nanosecond resolution, but you will not be sure of the measure's accuracy.



回答2:

In order to easily get time stamps with boost chrono for different measurements you can use boost CPU Timers. A table about the timer accuracy is also given on this site.

To measure the resolution yourself on your specific hardware use boost's cpu_timer_info.cpp.