I need to know the elapsed time of my program in seconds. Just the elapsed time, I'm not doing anything in between, so I DON'T need the time between two events, all I want to do is already in the code.
clock_t begin = clock();
float timeElapsed = (float)begin/(CLOCKS_PER_SEC);
cout << timeElapsed << endl;
The problem is, the "time" is being printed, but it is not in seconds. I even compared it with a chronometer, and it definitely is not in seconds. When something like "1.27818" appears on the screen, I expect it to be 1.27818 seconds, but it is clearly not. It takes too much time to get to 1 and this time is definitely not one second. What's going on? Wasn't "(float)begin/(CLOCKS_PER_SEC)" supposed to return in seconds?
UPDATE
I did this:
clock_t begin = clock();
float timeElapsed = (float)(clock() - begin)/(CLOCKS_PER_SEC);
cout << timeElapsed << endl;
But I'm getting values like these:
0
1e-06
1e-06
0
1e-06
1e-06
2e-06
1e-06