I just wrote this code:
Code:
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
clock_t clk1 = clock();
printf("%ld\n", clk1);
int i,r=0;
for(i = 0; i < 100000; i++) r^=rand();
printf("%d\n", r);
clock_t clk2 = clock();
printf("%ld\n", clk2);
return 0;
}
I also tried using a sleep() before the loop, in both cases, clk1 and clk2 both showing 0, why is that? Am I suppossed aren't they supposed to be showing approximate clock cycle count for the program? What am I doing wrong here?
Bookmarks