c++ - What are the uses of std::chrono::high_resolution_clock? -
at first thought can used performance measurements. said std::chrono::high_resolution_clock may not steady (is_steady may false). said std::chrono::high_resolution_clock may alias of std::chrono::system_clock not steady. can't measure time intervals type of clock because @ moment clock may adjusted , measurements wrong.
at same time can't convert time points of std::chrono::high_resolution_clock calendar time because doesn't have to_time_t method. can't real time type of clock either.
then can std::chrono::high_resolution_clock used for?
there none.
sorry, my bad.
if tempted use high_resolution_clock, choose steady_clock instead. on libc++ , vs high_resolution_clock type alias of steady_clock anyway.
on gcc high_resolution_clock type alias of system_clock , i've seen more 1 use of high_resolution_clock::to_time_t on platform (which wrong).
do use <chrono>. there parts of <chrono> should avoid.
- don't use
high_resoulution_clock. - avoid uses of
.count(),.time_since_epoch()unless there no other way job done. - avoid
duration_castunless code won't compile without it, , desire truncation-towards-zero behavior. - avoid explicit conversion syntax if implicit conversion compiles.
Comments
Post a Comment