My understanding is that C++ reorders code when optimizing and simple timers might not provide accurate results for timing execution time. Can someone provide an example where the following code could be reordered?
auto t0 = clock();
auto r = someLongRunningFunc();
auto t1 = clock();
std::cout << r << " time: " << t1 - t0 << std::endl;
to where someLongRunningFunc() is invoked before the first call to clock() or after the second call to clock()?
FWIW - I'm using Visual Studio 17, and I can't seem to write a function which accomplishes this.