In section 26.6.1 (Timing) Stroustrup in its book (Programming Principles And Practice Using C++ 2nd Edition May 2014) declare this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <chrono>
usingnamespace std;
int main()
{
int n = 1000000;
auto t1 = system_clock::now();
for (int i = 0; i < n; i++)
i += i;
auto t2 = system_clock::now();
cout << "The loop " << n << " times too "
<< dynamic_cast<milliseconds>(t2 - t1).count() << " milliseconds\n";
system("pause");
return 0;
}
#include <iostream>
#include <chrono>
usingnamespace std;
int main()
{
int n = 1000000;
auto t1 = std::chrono::system_clock::now();
for (int i = 0; i < n; i++)
i += i;
auto t2 = std::chrono::system_clock::now();
cout
<< "The loop " << n << " times too "
<< std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count() << " nanoseconds\n";
system("pause");
return 0;
}
My guess is it's #included in a Stroustrups facilities-library-type file. Details are probably somewhere in his fine print or on a web page. Who knows?