I am trying to use time() to measure various points of my program.
What I don\'t understand is why the values in the before and after are the same? I understand thi
Matlab
flavored!
tic
starts a stopwatch timer to measure performance. The function records the internal time at execution of the tic command. Display the elapsed time with the toc
function.
#include
#include
#include
using namespace std;
clock_t START_TIMER;
clock_t tic()
{
return START_TIMER = clock();
}
void toc(clock_t start = START_TIMER)
{
cout
<< "Elapsed time: "
<< (clock() - start) / (double)CLOCKS_PER_SEC << "s"
<< endl;
}
int main()
{
tic();
this_thread::sleep_for(2s);
toc();
return 0;
}