: Windows, , Visual Studio 2013 , , unprecise. - , , , ( 8 , ).
, (04/2014) VS (, condition_variable.wait_for() this_thread:: sleep_for()). , Boost, . STL (, Microsoft) , Visual Studio 2013 ( CTP, ).
, - ( , high_precision_clock ), , (GCC, Clang, Boost chrono ).
, GCC 4.8 (Coliru):
#include <iostream>
#include <chrono>
#include <vector>
#include <algorithm>
auto my_array = []{
std::vector<long long> values( 100000 );
long long last_value = 0;
for( auto& value : values )
value = last_value++;
return values;
}();
void some_work()
{
for( int i = 0; i < 10000; ++i )
std::reverse( begin(my_array), end(my_array) );
}
int main()
{
using namespace std;
using namespace chrono;
auto start = high_resolution_clock::now();
some_work();
auto end = high_resolution_clock::now();
auto totalTime = end - start;
cout << duration_cast<microseconds>(totalTime).count()<< " microsecs \n";
return 0;
}
Coliru "95 " some_work().