hola
im trying to time how long a program is running so as to get some sorta figures on bandwidth (data units per time period)
im using the following code: (condensed)
Code:
clock_t start, end;
struct tms t_start, t_end;
start = times(&t_start);
then i call the function
i have a finishup function that is called when the program either gets an error or gets a SIGINT
Code:
void finishup(int exitval) {
long tps = sysconf(_SC_CLK_TCK);
end = times(&t_end);
printf("elapsed: %6.2f secs\n", (float)(end - start)/tps);
printf("caught ctrl-c, received %i packets, cleaning up\n", pktno);
fclose(fout);
fclose(procinfo);
exit(exitval);
}
HOWEVER...!
the time it prints out is generally a lot less than the actual time it runs..
now i suspect its because im working on cpu time or thereabouts and not real time or IO time..
can anyone suggest a better way to do this (in C) as my books are at my birds
Slidey