probably doing something fundamentally wrong , but im used to the luxury of java's System.currentTimeMillis()
or System.nanoTime()
unfortunately. i have a code that i posted before for a different problem (couldnt compile properly in pelles C) , but now , although its compiling well and good , my clock outputs always give zero. any help here ?
my code :
#include<stdio.h>
#include<time.h>
int main(void){
long long int i = 0, y =0 , x = 7985463214932541; // x = a very big odd number
clock_t t1,t2;
printf("\n strating bitwise method :");
t1 = clock();
printf("\nstarting time : %ld\n",t1);
for(i = 0 ; i < 500000000 ; i++){
if(x&1) y=1;
}
t1 = clock() - t1;
printf("bitwise time : %15ld\n",t1);
y=0;
printf("\n strating mul div method : \n");
t2 = clock();
printf("starting time : %ld\n",t2);
for(i = 0; i < 500000000 ; i++){
if(((x/2)*2) != x ) y=1;
}
t2 = clock() - t2;
printf("\nmul-div time: %15ld\n\n",t2);
return 0;
}