In <chrono>, the standard library provides facilities for dealing with time durations and time points. All chrono facilities are in the std::chrono (sub)namespace, so we have to either explicitly qualify with chrono:: or add a using-directive:

using namespace std::chrono

If you want to know the current time, you can call now() . Below is the implementation:

#include<chrono> #include<ctime> #include<iostream> #include<ratio> using namespace std::chrono; using namespace std; int main() { steady_clock::time_point a = steady_clock::now(); for(int i=0;i<1000;i++); steady_clock::time_point b = steady_clock::now(); duration<double> time_span = duration_cast<duration<double> >(b-a); cout << "It took " << time_span.count()<< " seconds" << endl; return 0; } Output:./a.out It took 2.907e-06 seconds

If you have any feedback or comment please leave a reply.