I thought the best way to measure how efficient my program is was by checking the time it took it to run however when I do so I keep getting random times.
I'm using the following code as shown by Roger Pate in this this thread:
#include <ctime>
void func()
{
using namespace std;
clock_t begin = clock();
//Function to measure here
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
}
I think this is happening because I have a few programs running in the background.
I don't want to restart my computer every time I'd wanna recheck the time for my function so my question is: Is there a better way to measure a program's efficiency?
IDE is Codeblocks, OS is Win7 64bit.