int main() { time_t start, end; time(&start); // start time // {your code goes here} time(&end); // end time double time_taken = double(end - start); // calulate diffrence std::cout << " duration: " << time_taken << " s "; }