Nick
Nick

Reputation: 10539

what is gettimeofday() equivalent in c++11

Probably duplicate, but What is gettimeofday() equivalent in c++11 ?

I am trying to get 64 bit timestamp with microseconds, similar to Java / Python.

Upvotes: 3

Views: 4482

Answers (2)

Konrad Rudolph
Konrad Rudolph

Reputation: 545588

To get the highest resolution supported by your system, use std::high_resolution_clock::now. The high-resolution clock may be an alias for std::chrono::system_clock.

Upvotes: 2

wilx
wilx

Reputation: 18228

Use std::chrono::system_clock::now().

UPDATE

You can check the necessary minimal precision by this static assert:

static_assert (std::ratio_less_equal<std::chrono::system_clock::duration::period,
    std::ratio<1,100> >::value, "");

Upvotes: 5

Related Questions