std 3a 3aendl

Solutions on MaxInterview for std 3a 3aendl by the best coders in the world

showing results for - "std 3a 3aendl"
Addie
29 Sep 2018
1#include <iostream>
2#include <chrono>
3 
4template<typename Diff>
5void log_progress(Diff d)
6{
7    std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(d).count()
8              << " ms passed" << std::endl;
9}
10 
11int main()
12{
13    std::cout.sync_with_stdio(false); // on some platforms, stdout flushes on \n
14    volatile int sink = 0;
15 
16    auto t1 = std::chrono::high_resolution_clock::now();
17    for (int j=0; j<5; ++j)
18    {
19        for (int n=0; n<10000; ++n)
20            for (int m=0; m<20000; ++m)
21                sink += m*n; // do some work
22        auto now = std::chrono::high_resolution_clock::now();
23        log_progress(now - t1);
24    }
25}