I need to know how many times i spend to run a particular method in C but the timer does not work and it prints the value: 0.000000. I read that the right code is:
clock_t a,b;
a=clock();
//code...
b=clock();
double result =(double) (a-b)/CLOCKS_PER_SEC;
But it doesn't work with my program.
int calculate (char *file1, char *file2,int param,char* path ){
double timeSpent = 0.0;
clock_t begin,finish;
begin = clock();
int dim1=strlen(file1);
int dim2= strlen(file2);
int i;
int **ppm =matrix(file1,dim1,file2,dim2,createMatrix(dim1,dim2));
int distance = ppm[dim1][dim2];
struct Instruction istr[distance + 1];
int tmp = start(ppm, file1, &dim1, file2, &dim2, istr);
end(file1, &dim1, file2, &dim2, istr, tmp);
for (i = 0; i <= dim1; i++)
free(ppm[i]);
free(ppm);
if (numDiv > 0){
numDiv--;}
finish= clock();
timeSpent=(double ) (finish-begin)/CLOCKS_PER_SEC;
printf("time: %3f",timeSpent);
}