I have searched but I can't find an equivalent to the matlab tic/toc function to simply display on the console how long time took the program to do its processing. (ideally I would like to put the tic (start timer) and toc (end timer) anywhere in the program.
Any suggestions?
I found what I was looking for. Include:
#include <ctime>
Then at the beginning:
time_t tstart, tend;
tstart = time(0);
And finally before the end:
tend = time(0);
cout << "It took "<< difftime(tend, tstart) <<" second(s)."<< endl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With