So in my code below I loop doing:
1) create some data (the exact same data is created every time), and put it into a double array.
2) record clock time
3) process the data
4) calculate the elapsed time, and add it to the elapsed total
5) print out the running total
The first 50 or so times through the loop the elapsed time prints out as 0.0000000.....
Then all of a sudden it jumps to:
and stays there for the remainder of the 100 iterations, even though all 100 of the iterations take the same amount of time (or at least with a very small degree of variation).
Can anybody tell me what is up with this? I'm trying to get an average for how long the function takes to run.
int i = 0;
int numIterations = 100;
//complexData is a double 
while(i < numIterations)
before = clock();
processData(complexData-1, SIZE, 1);
elapsed = elapsed + ((clock()-before)/CLOCKS_PER_SEC);
printf("Time: %f\n", 1, (elapsed));
printf("Avg Time: %.6f\n", 1, (elapsed)/(double)numIterations);