¿Cómo obtener la precisión de high_resolution_clock?
C ++ 11 definehigh_resolution_clock
y tiene los tipos de miembrosperiod
yrep
. Pero no puedo entender cómo puedo obtener elprecisió de ese reloj.
O, si no puedo llegar a la precisión, ¿puedo obtener al menos un recuento en nanosegundos de duración de tiempo representable mínima entre garrapatas? probablemente usandoperiod
?
#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";
}