Main Page   File List   Globals  

timing.h

Go to the documentation of this file.
00001 // timing functions...
00002 
00005 #include <time.h>
00006 #include <sys/times.h>
00007 
00008 static long tps; // ticks per second
00009 static struct tms t;
00010 static clock_t t0,t1;
00011 
00013 double timing_init(FILE *f) {
00014   tps=sysconf(_SC_CLK_TCK); // ticks per second
00015   times(&t); 
00016   t0=t.tms_utime; 
00017   fprintf(f,"start: t0=%.2f seconds\n",t0/(double)tps);
00018   return t0/(double)tps;
00019 }
00020 
00022 double timing_end(FILE *f) {
00023   times(&t);
00024   t1=t.tms_utime;
00025   fprintf(f,"end: t1=%.2f seconds\n",t1/(double)tps);
00026   fprintf(f,"%f seconds user time elapsed\n",(double)(t1-t0)/tps);
00027   return (double)(t1-t0)/tps;
00028 }

Generated on Tue Jul 19 15:09:05 2005 for graphlib by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002