C ++ 11は定義high_resolution_clock
し、メンバータイプperiod
とを持っていますrep
。しかし、どうすればその時計の精度を得ることができるのか理解できません。
または、精度が得られない場合は、少なくともティック間の最小表現可能時間のナノ秒単位のカウントを取得できますか?おそらく使用してい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\n";
}