#include #include #include #include using namespace std; using namespace std::chrono; int main() { double d{0}, e{0}; auto start {chrono::high_resolution_clock::now()}; for(int i =0; i < 500'000'000; i++) { d+= cos (1/static_cast(i)); e+= sin (1/static_cast(i)); } auto end {chrono::high_resolution_clock::now()}; auto diff {end - start}; cout << "That took " << endl; cout << setprecision(15) << fixed ; cout << chrono::duration{diff}.count() << " ns" << endl; cout << chrono::duration{diff}.count() << " us" << endl; cout << chrono::duration{diff}.count() << " ms" << endl; cout << chrono::duration>{diff}.count() << " s" << endl; cout << chrono::duration>{diff}.count() << " m" << endl; auto min = duration_cast(diff); diff -= min; auto sec = duration_cast(diff ); diff -= sec; auto msec = duration_cast(diff ); diff -= msec; auto usec = duration_cast(diff); cout << endl << endl; cout << "Or " << endl; cout << min.count() << " min " << sec.count() << " sec " << msec.count() << " ms " << usec.count() << " us" << endl; long double finalus = ((min.count()*60 + sec.count())*1000 + msec.count())*1000 + usec.count(); cout << "Or " << finalus << endl; if (! isnan(e+d) ) { cout << e + d << endl; } return 0; }