Does anyone know an equivalent function of the gettimeofday() function in Windows environment? I am comparing a code execution time in Linux vs Windows. I am us
This is the version of c++11 that uses chrono.
Thank you, Howard Hinnant for advice.
#if defined(_WIN32)
#include
int gettimeofday(struct timeval* tp, struct timezone* tzp) {
namespace sc = std::chrono;
sc::system_clock::duration d = sc::system_clock::now().time_since_epoch();
sc::seconds s = sc::duration_cast(d);
tp->tv_sec = s.count();
tp->tv_usec = sc::duration_cast(d - s).count();
return 0;
}
#endif // _WIN32