C++11 defines high_resolution_clock
and it has the member types period
and rep
. But I can not figure out how I can get the precision of that clock.
Or, if I may not get to the precision, can I somehow at least get a count in nanoseconds of the minimum representable time duration between ticks? probably using period
?
#include <iostream>
#include <chrono>
void printPrec() {
std::chrono::high_resolution_clock::rep x = 1;
// this is not the correct way to initialize 'period':
//high_resolution_clock::period y = 1;
std::cout << "The smallest period is "
<< /* what to do with 'x' or 'y' here? */
<< " nanos
";
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…