Probably duplicate, but What is gettimeofday() equivalent in c++11 ?
I am trying to get 64 bit timestamp with microseconds, similar to Java / Python.
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, "");
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With