C++11 how to print out high resolution clock time_point

前端 未结 2 727
长情又很酷
长情又很酷 2020-12-31 08:22

How do I print out a time_point when the time_point is obtained from high_resolution_clock?

timestamp = std::chrono::high_resolution_clock::now();
std::time_         


        
2条回答
  •  攒了一身酷
    2020-12-31 08:44

    At least as I read things, the intent is that std::high_resolution_clock could be defined as a wrapper around something like a CPU's time-stamp counter, that's simply a register that's incremented every CPU clock cycle.

    That's not necessarily the case (and with current systems constantly modifying CPU clock frequency probably a poor idea), but other similar clocks are also intended to be supported.

    Bottom line: there may not be a known relationship between absolute time and the high-resolution clock, so it's really defined only to produce durations, not absolute times.

提交回复
热议问题