im trying to time a system call.
I want to use/ understand the times() function. but it doesnt seem to work.
both calls to the times() function return the same value. It must have something to do with the values im passing in but i dont know how...
possibly b/c they're not inititlised?
how do i initialise them?
clock_t start, end;
struct tms buffer;
start = times(buffer); /*num of clocks time */
for(i=0; i<1000; i++) /* time 100 times */
end = (clock_t) times(buffer);
/* num of clocks time*/
/*end-start, divided by number of clocks a sec */
difference = (double) (end - start ) / sysconf(_SC_CLK_TCK);
difference = difference /1000;
/*repeated 1000 times */
printf("time taken: %llf\n", (difference));
can anyone help me?