hey all,
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?
<CODE>
#include <sys/times.h>
#include <unistd.h>
int main()
{
clock_t start, end;
struct tms buffer[4];
double difference;
int i;
start = times(buffer); /*num of clocks time */
for(i=0; i<1000; i++) /* time 100 times */
{
getpid();
}
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));
return 1;
}
</CODE>
can anyone help me?
cheers,