vendredi 7 avril 2017

std::chrono::system_clock vs std::chrono::high_resolution_clock behavior

Consider the following code snippet:

int main()
{
     auto result1 = std::chrono::duration_cast<std::chrono::seconds(std::chrono::high_resolution_clock::now().time_since_epoch());
     auto result2 = std::chrono::duration_cast<std::chrono::seconds(std::chrono::system_clock::now().time_since_epoch());
     assert((result2.count() - result1.count()) < 10);
}

I am expecting that the difference in counts between the two values should be minimal (ideally less than a second). But with VS2015, the difference in count is of the order of Billions of seconds. How is this possible?

Aucun commentaire:

Enregistrer un commentaire