C ++ 11/14 gives you more efficient ways than the old one #include<ctime> headers of C
for measuring time duration
, using specific classes, such as steady_clock
, high_resolution_clock
etc., defined in the header #include<chrono>
. The following code does your work very efficiently: -
#include <iostream>
#include <chrono>
using namespace std;
int main()
{
chrono::steady_clock sc;
auto start = sc.now();
auto end = sc.now();
auto time_span = static_cast<chrono::duration<double>>(end - start);
cout<<"Operation took: "<<time_span.count()<<" seconds !!!";
return 0;
}
And you finished with your work !!!!! It may seem strange at the beginning, but it works very well without any problems. Hope your problem is resolved.
source
share